summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_complex.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-03-31 22:01:03 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-03-31 22:01:03 (GMT)
commit6257a7bbb2660ae75c44f2e71d7ac2ce73900f74 (patch)
tree6f010065c95f2d5617f56e07ba2628be21cf9d7a /Lib/test/test_complex.py
parentad5983364966b49c277b495112ae41c6ae2d01ed (diff)
downloadcpython-6257a7bbb2660ae75c44f2e71d7ac2ce73900f74.zip
cpython-6257a7bbb2660ae75c44f2e71d7ac2ce73900f74.tar.gz
cpython-6257a7bbb2660ae75c44f2e71d7ac2ce73900f74.tar.bz2
Replace catch_warnings with check_warnings when it makes sense. Use assertRaises context manager to simplify some tests.
Diffstat (limited to 'Lib/test/test_complex.py')
-rw-r--r--Lib/test/test_complex.py18
1 files changed, 5 insertions, 13 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py
index eb04856..fc47b23 100644
--- a/Lib/test/test_complex.py
+++ b/Lib/test/test_complex.py
@@ -1,13 +1,6 @@
-import unittest, os
+import unittest
from test import test_support
-import warnings
-warnings.filterwarnings(
- "ignore",
- category=DeprecationWarning,
- message=".*complex divmod.*are deprecated"
-)
-
from random import random
from math import atan2, isnan, copysign
@@ -464,10 +457,7 @@ class ComplexTest(unittest.TestCase):
finally:
if (fo is not None) and (not fo.closed):
fo.close()
- try:
- os.remove(test_support.TESTFN)
- except (OSError, IOError):
- pass
+ test_support.unlink(test_support.TESTFN)
def test_getnewargs(self):
self.assertEqual((1+2j).__getnewargs__(), (1.0, 2.0))
@@ -613,7 +603,9 @@ class ComplexTest(unittest.TestCase):
self.assertEqual('{0:F}'.format(complex(NAN, NAN)), 'NAN+NANj')
def test_main():
- test_support.run_unittest(ComplexTest)
+ with test_support.check_warnings(("complex divmod.., // and % are "
+ "deprecated", DeprecationWarning)):
+ test_support.run_unittest(ComplexTest)
if __name__ == "__main__":
test_main()