From 5c4ef3ddecbbc21e4f18a6c91483594db375ee27 Mon Sep 17 00:00:00 2001 From: "mark.dickinson" Date: Mon, 21 Dec 2009 16:29:21 +0000 Subject: [PATCH] Issue #7553: test_long_future wasn't testing properly. Thanks Florent Xicluna for bug report and patch. git-svn-id: http://svn.python.org/projects/python/trunk@76984 6015fed2-1504-0410-9fe1-9d1591cc4771 --- Lib/test/test_long_future.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Lib/test/test_long_future.py b/Lib/test/test_long_future.py index 9044da6b6d..8b8e7d68ca 100644 --- a/Lib/test/test_long_future.py +++ b/Lib/test/test_long_future.py @@ -30,22 +30,20 @@ class TrueDivisionTests(unittest.TestCase): for overflow in ["float(huge)", "float(mhuge)", "huge / 1", "huge / 2L", "huge / -1", "huge / -2L", "mhuge / 100", "mhuge / 100L"]: - # XXX(cwinter) this test doesn't pass when converted to - # use assertRaises. - try: + # If the "eval" does not happen in this module, + # true division is not enabled + with self.assertRaises(OverflowError): eval(overflow, namespace) - self.fail("expected OverflowError from %r" % overflow) - except OverflowError: - pass for underflow in ["1 / huge", "2L / huge", "-1 / huge", "-2L / huge", "100 / mhuge", "100L / mhuge"]: result = eval(underflow, namespace) - self.assertEqual(result, 0.0, - "expected underflow to 0 from %r" % underflow) + self.assertEqual(result, 0.0, 'expected underflow to 0 ' + 'from {!r}'.format(underflow)) for zero in ["huge / 0", "huge / 0L", "mhuge / 0", "mhuge / 0L"]: - self.assertRaises(ZeroDivisionError, eval, zero, namespace) + with self.assertRaises(ZeroDivisionError): + eval(zero, namespace) def test_main(): -- 2.11.4.GIT