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

Method test_repr_str

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

Source from the content-addressed store, hash-verified

784 self.assertRaises(OverflowError, abs, complex(DBL_MAX, DBL_MAX))
785
786 def test_repr_str(self):
787 def test(v, expected, test_fn=self.assertEqual):
788 test_fn(repr(v), expected)
789 test_fn(str(v), expected)
790
791 test(1+6j, '(1+6j)')
792 test(1-6j, '(1-6j)')
793
794 test(-(1+0j), '(-1+-0j)', test_fn=self.assertNotEqual)
795
796 test(complex(1., INF), "(1+infj)")
797 test(complex(1., -INF), "(1-infj)")
798 test(complex(INF, 1), "(inf+1j)")
799 test(complex(-INF, INF), "(-inf+infj)")
800 test(complex(NAN, 1), "(nan+1j)")
801 test(complex(1, NAN), "(1+nanj)")
802 test(complex(NAN, NAN), "(nan+nanj)")
803 test(complex(-NAN, -NAN), "(nan+nanj)")
804
805 test(complex(0, INF), "infj")
806 test(complex(0, -INF), "-infj")
807 test(complex(0, NAN), "nanj")
808
809 self.assertEqual(1-6j,complex(repr(1-6j)))
810 self.assertEqual(1+6j,complex(repr(1+6j)))
811 self.assertEqual(-6j,complex(repr(-6j)))
812 self.assertEqual(6j,complex(repr(6j)))
813
814 @support.requires_IEEE_754
815 def test_negative_zero_repr_str(self):

Callers

nothing calls this directly

Calls 2

testFunction · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected