diff options
author | Stefan Krah <skrah@bytereef.org> | 2012-04-02 17:10:20 (GMT) |
---|---|---|
committer | Stefan Krah <skrah@bytereef.org> | 2012-04-02 17:10:20 (GMT) |
commit | 9d2801095f6186a0993259fe558a22c27abeb8be (patch) | |
tree | d2c8064778855f0f37be4acc0d6c6a0aeaf96de0 /Lib/test/test_decimal.py | |
parent | 368b4b74050290a77f32cafa8c7fac3542bc6308 (diff) | |
download | cpython-9d2801095f6186a0993259fe558a22c27abeb8be.zip cpython-9d2801095f6186a0993259fe558a22c27abeb8be.tar.gz cpython-9d2801095f6186a0993259fe558a22c27abeb8be.tar.bz2 |
Testing the implicit initialization of the thread local context on first
access fails (expectedly) if other modules have already used decimal. The
only option is to remove the test.
Diffstat (limited to 'Lib/test/test_decimal.py')
-rw-r--r-- | Lib/test/test_decimal.py | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 286d82c..694b959 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -56,76 +56,6 @@ sys.modules['decimal'] = C fractions = {C:cfractions, P:pfractions} sys.modules['decimal'] = orig_sys_decimal -############ RunFirst ############ -class RunFirst(unittest.TestCase): - - def setUp(self): - self.save_default = self.decimal.DefaultContext.copy() - - def tearDown(self): - DefaultContext = self.decimal.DefaultContext - - DefaultContext.prec = self.save_default.prec - DefaultContext.rounding = self.save_default.rounding - DefaultContext.Emax = self.save_default.Emax - DefaultContext.Emin = self.save_default.Emin - DefaultContext.capitals = self.save_default.capitals - DefaultContext.clamp = self.save_default.clamp - DefaultContext.flags = self.save_default.flags - DefaultContext.traps = self.save_default.traps - - self.decimal.setcontext(self.decimal.DefaultContext) - - def test_00default_context(self): - # The test depends on the fact that getcontext() is called - # for the first time. - DefaultContext = self.decimal.DefaultContext - ROUND_05UP = self.decimal.ROUND_05UP - Clamped = self.decimal.Clamped - InvalidOperation = self.decimal.InvalidOperation - - DefaultContext.prec = 5001 - DefaultContext.rounding = ROUND_05UP - DefaultContext.Emax = 10025 - DefaultContext.Emin = -10025 - DefaultContext.capitals = 0 - DefaultContext.clamp = 1 - DefaultContext.flags[InvalidOperation] = True - DefaultContext.clear_traps() - DefaultContext.traps[Clamped] = True - - # implicit initialization on first access - c = self.decimal.getcontext() - - self.assertEqual(c.prec, 5001) - self.assertEqual(c.rounding, ROUND_05UP) - self.assertEqual(c.Emax, 10025) - self.assertEqual(c.Emin, -10025) - self.assertEqual(c.capitals, 0) - self.assertEqual(c.clamp, 1) - for k in c.flags: - self.assertFalse(c.flags[k]) - for k in c.traps: - if k is Clamped: - self.assertTrue(c.traps[k]) - else: - self.assertFalse(c.traps[k]) - - # explicit initialization - self.decimal.setcontext(DefaultContext) - c = self.decimal.getcontext() - for k in c.flags: - self.assertFalse(c.flags[k]) - -class CRunFirst(RunFirst): - decimal = C -class PyRunFirst(RunFirst): - decimal = P -if C: - run_unittest(CRunFirst, PyRunFirst) -else: - run_unittest(PyRunFirst) -############ END RunFirst ############ # Useful Test Constant Signals = { |