mirror of
https://github.com/python/cpython.git
synced 2025-09-15 05:06:12 +00:00
gh-126947: Typechecking for _pydatetime.timedelta.__new__ arguments (#126949)
Co-authored-by: sobolevn <mail@sobolevn.me> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
parent
88dc84bcf9
commit
8da9920a80
3 changed files with 25 additions and 1 deletions
|
@ -510,6 +510,7 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
|
|||
|
||||
def test_constructor(self):
|
||||
eq = self.assertEqual
|
||||
ra = self.assertRaises
|
||||
td = timedelta
|
||||
|
||||
# Check keyword args to constructor
|
||||
|
@ -533,6 +534,15 @@ class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
|
|||
eq(td(seconds=0.001), td(milliseconds=1))
|
||||
eq(td(milliseconds=0.001), td(microseconds=1))
|
||||
|
||||
# Check type of args to constructor
|
||||
ra(TypeError, lambda: td(weeks='1'))
|
||||
ra(TypeError, lambda: td(days='1'))
|
||||
ra(TypeError, lambda: td(hours='1'))
|
||||
ra(TypeError, lambda: td(minutes='1'))
|
||||
ra(TypeError, lambda: td(seconds='1'))
|
||||
ra(TypeError, lambda: td(milliseconds='1'))
|
||||
ra(TypeError, lambda: td(microseconds='1'))
|
||||
|
||||
def test_computations(self):
|
||||
eq = self.assertEqual
|
||||
td = timedelta
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue