MCPcopy Index your code
hub / github.com/python/cpython / test_constructor_special_numbers

Method test_constructor_special_numbers

Lib/test/test_complex.py:642–660  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

640
641 @support.requires_IEEE_754
642 def test_constructor_special_numbers(self):
643 for x in 0.0, -0.0, INF, -INF, NAN:
644 for y in 0.0, -0.0, INF, -INF, NAN:
645 with self.subTest(x=x, y=y):
646 z = complex(x, y)
647 self.assertFloatsAreIdentical(z.real, x)
648 self.assertFloatsAreIdentical(z.imag, y)
649 z = ComplexSubclass(x, y)
650 self.assertIs(type(z), ComplexSubclass)
651 self.assertFloatsAreIdentical(z.real, x)
652 self.assertFloatsAreIdentical(z.imag, y)
653 z = complex(ComplexSubclass(x, y))
654 self.assertIs(type(z), complex)
655 self.assertFloatsAreIdentical(z.real, x)
656 self.assertFloatsAreIdentical(z.imag, y)
657 z = ComplexSubclass(complex(x, y))
658 self.assertIs(type(z), ComplexSubclass)
659 self.assertFloatsAreIdentical(z.real, x)
660 self.assertFloatsAreIdentical(z.imag, y)
661
662 def test_constructor_from_string(self):
663 def check(z, x, y):

Callers

nothing calls this directly

Calls 4

ComplexSubclassClass · 0.70
subTestMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected