MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_constructor

Method test_constructor

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

Source from the content-addressed store, hash-verified

513 theclass = timedelta
514
515 def test_constructor(self):
516 eq = self.assertEqual
517 ra = self.assertRaises
518 td = timedelta
519
520 # Check keyword args to constructor
521 eq(td(), td(weeks=0, days=0, hours=0, minutes=0, seconds=0,
522 milliseconds=0, microseconds=0))
523 eq(td(1), td(days=1))
524 eq(td(0, 1), td(seconds=1))
525 eq(td(0, 0, 1), td(microseconds=1))
526 eq(td(weeks=1), td(days=7))
527 eq(td(days=1), td(hours=24))
528 eq(td(hours=1), td(minutes=60))
529 eq(td(minutes=1), td(seconds=60))
530 eq(td(seconds=1), td(milliseconds=1000))
531 eq(td(milliseconds=1), td(microseconds=1000))
532
533 # Check float args to constructor
534 eq(td(weeks=1.0/7), td(days=1))
535 eq(td(days=1.0/24), td(hours=1))
536 eq(td(hours=1.0/60), td(minutes=1))
537 eq(td(minutes=1.0/60), td(seconds=1))
538 eq(td(seconds=0.001), td(milliseconds=1))
539 eq(td(milliseconds=0.001), td(microseconds=1))
540
541 # Check type of args to constructor
542 ra(TypeError, lambda: td(weeks='1'))
543 ra(TypeError, lambda: td(days='1'))
544 ra(TypeError, lambda: td(hours='1'))
545 ra(TypeError, lambda: td(minutes='1'))
546 ra(TypeError, lambda: td(seconds='1'))
547 ra(TypeError, lambda: td(milliseconds='1'))
548 ra(TypeError, lambda: td(microseconds='1'))
549
550 def test_computations(self):
551 eq = self.assertEqual

Callers

nothing calls this directly

Calls 1

eqFunction · 0.90

Tested by

no test coverage detected