mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
Replace catch_warnings with check_warnings when it makes sense. Use assertRaises context manager to simplify some tests.
This commit is contained in:
parent
ad59833649
commit
6257a7bbb2
21 changed files with 112 additions and 226 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue