MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_localcontext

Method test_localcontext

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

Source from the content-addressed store, hash-verified

3711 # as doctest can't handle __future__ statements
3712
3713 def test_localcontext(self):
3714 # Use a copy of the current context in the block
3715 getcontext = self.decimal.getcontext
3716 localcontext = self.decimal.localcontext
3717
3718 orig_ctx = getcontext()
3719 with localcontext() as enter_ctx:
3720 set_ctx = getcontext()
3721 final_ctx = getcontext()
3722 self.assertIs(orig_ctx, final_ctx, 'did not restore context correctly')
3723 self.assertIsNot(orig_ctx, set_ctx, 'did not copy the context')
3724 self.assertIs(set_ctx, enter_ctx, '__enter__ returned wrong context')
3725
3726 def test_localcontextarg(self):
3727 # 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