Skip to content

Commit 3307865

Browse files
committed
Use generated test cases instead of manual list
1 parent 958ffff commit 3307865

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

Lib/test/datetimetester.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -1848,18 +1848,23 @@ def test_fromisocalendar_value_errors(self):
18481848
self.theclass.fromisocalendar(*isocal)
18491849

18501850
def test_fromisocalendar_type_errors(self):
1851-
isocals = [
1852-
("2019", 1, 1),
1853-
(2019, "1", 1),
1854-
(2019, 1, "1"),
1855-
(None, 1, 1),
1856-
(2019, None, 1),
1857-
(2019, 1, None),
1858-
(2019.0, 1, 1),
1859-
(2019, 1.0, 1),
1860-
(2019, 1, 1.0),
1851+
err_txformers = [
1852+
str,
1853+
float,
1854+
lambda x: None,
18611855
]
18621856

1857+
# Take a valid base tuple and transform it to contain one argument
1858+
# with the wrong type. Repeat this for each argument, e.g.
1859+
# [("2019", 1, 1), (2019, "1", 1), (2019, 1, "1"), ...]
1860+
isocals = []
1861+
base = (2019, 1, 1)
1862+
for i in range(3):
1863+
for txformer in err_txformers:
1864+
err_val = list(base)
1865+
err_val[i] = txformer(err_val[i])
1866+
isocals.append(tuple(err_val))
1867+
18631868
for isocal in isocals:
18641869
with self.subTest(isocal=isocal):
18651870
with self.assertRaises(TypeError):

0 commit comments

Comments
 (0)