MCPcopy Index your code
hub / github.com/python/cpython / test_localcontext

Method test_localcontext

Lib/test/test_decimal.py:3708–3719  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3706 # as doctest can't handle __future__ statements
3707
3708 def test_localcontext(self):
3709 # Use a copy of the current context in the block
3710 getcontext = self.decimal.getcontext
3711 localcontext = self.decimal.localcontext
3712
3713 orig_ctx = getcontext()
3714 with localcontext() as enter_ctx:
3715 set_ctx = getcontext()
3716 final_ctx = getcontext()
3717 self.assertIs(orig_ctx, final_ctx, 'did not restore context correctly')
3718 self.assertIsNot(orig_ctx, set_ctx, 'did not copy the context')
3719 self.assertIs(set_ctx, enter_ctx, '__enter__ returned wrong context')
3720
3721 def test_localcontextarg(self):
3722 # Use a copy of the supplied context in the block

Callers

nothing calls this directly

Calls 4

getcontextFunction · 0.85
localcontextFunction · 0.85
assertIsNotMethod · 0.80
assertIsMethod · 0.45

Tested by

no test coverage detected