GeezerVison is showing github.com — Use generated test cases instead of manual list · python/cpython@3307865
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Lib/test/datetimetester.py +15-10Lines changed: 15 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1848,18 +1848,23 @@ def test_fromisocalendar_value_errors(self): | 1848 | 1848 | self.theclass.fromisocalendar(*isocal) | 1849 | 1849 |
| 1850 | 1850 | 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, | 1861 | 1855 | ] | 1862 | 1856 |
| | 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 | + | 1863 | 1868 | for isocal in isocals: | 1864 | 1869 | with self.subTest(isocal=isocal): | 1865 | 1870 | with self.assertRaises(TypeError): | |
|