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

Method test_localcontextarg

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

Source from the content-addressed store, hash-verified

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
3723 Context = self.decimal.Context
3724 getcontext = self.decimal.getcontext
3725 localcontext = self.decimal.localcontext
3726
3727 localcontext = self.decimal.localcontext
3728 orig_ctx = getcontext()
3729 new_ctx = Context(prec=42)
3730 with localcontext(new_ctx) as enter_ctx:
3731 set_ctx = getcontext()
3732 final_ctx = getcontext()
3733 self.assertIs(orig_ctx, final_ctx, 'did not restore context correctly')
3734 self.assertEqual(set_ctx.prec, new_ctx.prec, 'did not set correct context')
3735 self.assertIsNot(new_ctx, set_ctx, 'did not copy the context')
3736 self.assertIs(set_ctx, enter_ctx, '__enter__ returned wrong context')
3737
3738 def test_localcontext_kwargs(self):
3739 with self.decimal.localcontext(

Callers

nothing calls this directly

Calls 6

getcontextFunction · 0.85
localcontextFunction · 0.85
assertIsNotMethod · 0.80
ContextClass · 0.70
assertIsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected