summaryrefslogtreecommitdiffstats
path: root/Lib/test/datetimetester.py
diff options
context:
space:
mode:
authorBeomsoo Kim <beoms424@gmail.com>2024-11-19 19:40:52 (GMT)
committerGitHub <noreply@github.com>2024-11-19 19:40:52 (GMT)
commit8da9920a80c60fb3fc326c623e0f217c84011c1d (patch)
treed60e93bcdc7fbdf47c46b2f508094d808534776c /Lib/test/datetimetester.py
parent88dc84bcf9fef32afa9af0ab41fa467c9733483f (diff)
downloadcpython-8da9920a80c60fb3fc326c623e0f217c84011c1d.zip
cpython-8da9920a80c60fb3fc326c623e0f217c84011c1d.tar.gz
cpython-8da9920a80c60fb3fc326c623e0f217c84011c1d.tar.bz2
gh-126947: Typechecking for _pydatetime.timedelta.__new__ arguments (#126949)
Co-authored-by: sobolevn <mail@sobolevn.me> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Diffstat (limited to 'Lib/test/datetimetester.py')
-rw-r--r--Lib/test/datetimetester.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index dbe25ef..25a3015 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -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