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

Method test_replace

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

Source from the content-addressed store, hash-verified

3244 self.assertEqual(dt.time(), t)
3245
3246 def test_replace(self):
3247 cls = self.theclass
3248 args = [1, 2, 3, 4, 5, 6, 7]
3249 base = cls(*args)
3250 self.assertEqual(base.replace(), base)
3251 self.assertEqual(copy.replace(base), base)
3252
3253 changes = (("year", 2),
3254 ("month", 3),
3255 ("day", 4),
3256 ("hour", 5),
3257 ("minute", 6),
3258 ("second", 7),
3259 ("microsecond", 8))
3260 for i, (name, newval) in enumerate(changes):
3261 newargs = args[:]
3262 newargs[i] = newval
3263 expected = cls(*newargs)
3264 self.assertEqual(base.replace(**{name: newval}), expected)
3265 self.assertEqual(copy.replace(base, **{name: newval}), expected)
3266
3267 # Out of bounds.
3268 base = cls(2000, 2, 29)
3269 self.assertRaises(ValueError, base.replace, year=2001)
3270 self.assertRaises(ValueError, copy.replace, base, year=2001)
3271
3272 @support.run_with_tz('EDT4')
3273 def test_astimezone(self):

Callers

nothing calls this directly

Calls 5

enumerateFunction · 0.85
clsClass · 0.50
assertEqualMethod · 0.45
replaceMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected