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

Method test_localcontextarg

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

Source from the content-addressed store, hash-verified

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