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

Method test_str

Lib/test/datetimetester.py:760–782  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

758 self.assertRaises(TypeError, lambda: badarg >= t1)
759
760 def test_str(self):
761 td = timedelta
762 eq = self.assertEqual
763
764 eq(str(td(1)), "1 day, 0:00:00")
765 eq(str(td(-1)), "-1 day, 0:00:00")
766 eq(str(td(2)), "2 days, 0:00:00")
767 eq(str(td(-2)), "-2 days, 0:00:00")
768
769 eq(str(td(hours=12, minutes=58, seconds=59)), "12:58:59")
770 eq(str(td(hours=2, minutes=3, seconds=4)), "2:03:04")
771 eq(str(td(weeks=-30, hours=23, minutes=12, seconds=34)),
772 "-210 days, 23:12:34")
773
774 eq(str(td(milliseconds=1)), "0:00:00.001000")
775 eq(str(td(microseconds=3)), "0:00:00.000003")
776
777 eq(str(td(days=999999999, hours=23, minutes=59, seconds=59,
778 microseconds=999999)),
779 "999999999 days, 23:59:59.999999")
780
781 # test the Doc/library/datetime.rst recipe
782 eq(f'-({-td(hours=-1)!s})', "-(1:00:00)")
783
784 def test_repr(self):
785 name = 'datetime.' + self.theclass.__name__

Callers

nothing calls this directly

Calls 2

eqFunction · 0.90
strFunction · 0.85

Tested by

no test coverage detected