diff options
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | Lib/test/test_complex.py | 12 | ||||
| -rw-r--r-- | Lib/test/test_doctest.py | 2 | ||||
| -rw-r--r-- | Lib/test/test_typing.py | 2 |
3 files changed, 14 insertions, 2 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py index abd7e39..1cd025e 100644 --- a/Lib/test/test_complex.py +++ b/Lib/test/test_complex.py @@ -499,6 +499,18 @@ class ComplexTest(unittest.TestCase): self.assertEqual(complex(complex1(1j)), 2j) self.assertRaises(TypeError, complex, complex2(1j)) + def test___complex__(self): + z = 3 + 4j + self.assertEqual(z.__complex__(), z) + self.assertEqual(type(z.__complex__()), complex) + + class complex_subclass(complex): + pass + + z = complex_subclass(3 + 4j) + self.assertEqual(z.__complex__(), 3 + 4j) + self.assertEqual(type(z.__complex__()), complex) + @support.requires_IEEE_754 def test_constructor_special_numbers(self): class complex2(complex): diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py index 8f761d7..571dc78 100644 --- a/Lib/test/test_doctest.py +++ b/Lib/test/test_doctest.py @@ -668,7 +668,7 @@ plain ol' Python and is guaranteed to be available. >>> import builtins >>> tests = doctest.DocTestFinder().find(builtins) - >>> 816 < len(tests) < 836 # approximate number of objects with docstrings + >>> 820 < len(tests) < 840 # approximate number of objects with docstrings True >>> real_tests = [t for t in tests if len(t.examples) > 0] >>> len(real_tests) # objects that actually have doctests diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 3bd5894..84521ee 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -1533,11 +1533,11 @@ class ProtocolTests(BaseTestCase): def test_supports_complex(self): - # Note: complex itself doesn't have __complex__. class C: def __complex__(self): return 0j + self.assertIsSubclass(complex, typing.SupportsComplex) self.assertIsSubclass(C, typing.SupportsComplex) self.assertNotIsSubclass(str, typing.SupportsComplex) |
