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

Method test_with_statements_gc3

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

Source from the content-addressed store, hash-verified

3833 del c4
3834
3835 def test_with_statements_gc3(self):
3836 Context = self.decimal.Context
3837 localcontext = self.decimal.localcontext
3838 getcontext = self.decimal.getcontext
3839 setcontext = self.decimal.setcontext
3840
3841 with localcontext() as c1:
3842 del c1
3843 n1 = Context(prec=1)
3844 setcontext(n1)
3845 with localcontext(n1) as c2:
3846 del n1
3847 self.assertEqual(c2.prec, 1)
3848 del c2
3849 n2 = Context(prec=2)
3850 setcontext(n2)
3851 del n2
3852 self.assertEqual(getcontext().prec, 2)
3853 n3 = Context(prec=3)
3854 setcontext(n3)
3855 self.assertEqual(getcontext().prec, 3)
3856 with localcontext(n3) as c3:
3857 del n3
3858 self.assertEqual(c3.prec, 3)
3859 del c3
3860 n4 = Context(prec=4)
3861 setcontext(n4)
3862 del n4
3863 self.assertEqual(getcontext().prec, 4)
3864 with localcontext() as c4:
3865 self.assertEqual(c4.prec, 4)
3866 del c4
3867
3868@requires_cdecimal
3869class CContextWithStatement(ContextWithStatement, unittest.TestCase):

Callers

nothing calls this directly

Calls 5

localcontextFunction · 0.85
setcontextFunction · 0.85
getcontextFunction · 0.85
ContextClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected