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

Method test_roundtrip

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

Source from the content-addressed store, hash-verified

1232 self.assertEqual(dt.day, 1)
1233
1234 def test_roundtrip(self):
1235 for dt in (self.theclass(1, 2, 3),
1236 self.theclass.today()):
1237 # Verify dt -> string -> date identity.
1238 s = repr(dt)
1239 self.assertStartsWith(s, 'datetime.')
1240 s = s[9:]
1241 dt2 = eval(s)
1242 self.assertEqual(dt, dt2)
1243
1244 # Verify identity via reconstructing from pieces.
1245 dt2 = self.theclass(dt.year, dt.month, dt.day)
1246 self.assertEqual(dt, dt2)
1247
1248 def test_repr_subclass(self):
1249 """Subclasses should have bare names in the repr (gh-107773)."""

Callers

nothing calls this directly

Calls 3

todayMethod · 0.80
assertStartsWithMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected