diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-24 19:28:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-24 19:28:43 (GMT) |
commit | 671079ef6063fe227460a6c3114625fb6282bbd0 (patch) | |
tree | 1b43f7ca1513741277932d064bcd9367dff88443 /Lib | |
parent | af7b9ec5c855366feef4c67dc492d64b3baf84ca (diff) | |
download | cpython-671079ef6063fe227460a6c3114625fb6282bbd0.zip cpython-671079ef6063fe227460a6c3114625fb6282bbd0.tar.gz cpython-671079ef6063fe227460a6c3114625fb6282bbd0.tar.bz2 |
bpo-29894: Deprecate returning an instance of complex subclass from __complex__. (#798)
In a future versions of Python this can be an error.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_complex.py | 5 | ||||
-rw-r--r-- | Lib/test/test_getargs2.py | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py index cee4934..2d883c5 100644 --- a/Lib/test/test_complex.py +++ b/Lib/test/test_complex.py @@ -383,8 +383,9 @@ class ComplexTest(unittest.TestCase): def __complex__(self): return None - self.assertAlmostEqual(complex(complex0(1j)), 42j) - self.assertAlmostEqual(complex(complex1(1j)), 2j) + self.assertEqual(complex(complex0(1j)), 42j) + with self.assertWarns(DeprecationWarning): + self.assertEqual(complex(complex1(1j)), 2j) self.assertRaises(TypeError, complex, complex2(1j)) @support.requires_IEEE_754 diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py index 8a194aa..e5d9aa6 100644 --- a/Lib/test/test_getargs2.py +++ b/Lib/test/test_getargs2.py @@ -408,7 +408,8 @@ class Float_TestCase(unittest.TestCase): self.assertEqual(getargs_D(ComplexSubclass(7.5+0.25j)), 7.5+0.25j) self.assertEqual(getargs_D(ComplexSubclass2(7.5+0.25j)), 7.5+0.25j) self.assertRaises(TypeError, getargs_D, BadComplex()) - self.assertEqual(getargs_D(BadComplex2()), 4.25+0.5j) + with self.assertWarns(DeprecationWarning): + self.assertEqual(getargs_D(BadComplex2()), 4.25+0.5j) self.assertEqual(getargs_D(BadComplex3(7.5+0.25j)), 7.5+0.25j) for x in (DBL_MIN, -DBL_MIN, DBL_MAX, -DBL_MAX, INF, -INF): |