Revert "bpo-30822: Fix testing of datetime module." (#2588) · python/cpython@8207c17 (original) (raw)

4 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -2271,8 +2271,7 @@ def _name_from_offset(delta):
2271 2271 _check_tzinfo_arg, _check_tzname, _check_utc_offset, _cmp, _cmperror,
2272 2272 _date_class, _days_before_month, _days_before_year, _days_in_month,
2273 2273 _format_time, _is_leap, _isoweek1monday, _math, _ord2ymd,
2274 -_time, _time_class, _tzinfo_class, _wrap_strftime, _ymd2ord,
2275 -_divide_and_round)
2274 +_time, _time_class, _tzinfo_class, _wrap_strftime, _ymd2ord)
2276 2275 # XXX Since import * above excludes names that start with _,
2277 2276 # docstring does not get overwritten. In the future, it may be
2278 2277 # appropriate to maintain a single module level docstring and
Original file line number Diff line number Diff line change
@@ -61,9 +61,8 @@ def test_constants(self):
61 61 self.assertEqual(datetime.MAXYEAR, 9999)
62 62
63 63 def test_name_cleanup(self):
64 -if '_Pure' in self.__class__.__name__:
65 -self.skipTest('Only run for Fast C implementation')
66 -
64 +if '_Fast' not in str(self):
65 +return
67 66 datetime = datetime_module
68 67 names = set(name for name in dir(datetime)
69 68 if not name.startswith('__') and not name.endswith('__'))
@@ -73,9 +72,8 @@ def test_name_cleanup(self):
73 72 self.assertEqual(names - allowed, set([]))
74 73
75 74 def test_divide_and_round(self):
76 -if '_Fast' in self.__class__.__name__:
77 -self.skipTest('Only run for Pure Python implementation')
78 -
75 +if '_Fast' in str(self):
76 +return
79 77 dar = datetime_module._divide_and_round
80 78
81 79 self.assertEqual(dar(-10, -3), 3)
@@ -2853,7 +2851,7 @@ def tzname(self, dt): return self.tz
2853 2851 self.assertRaises(TypeError, t.strftime, "%Z")
2854 2852
2855 2853 # Issue #6697:
2856 -if '_Fast' in self.__class__.__name__:
2854 +if '_Fast' in str(self):
2857 2855 Badtzname.tz = '\ud800'
2858 2856 self.assertRaises(ValueError, t.strftime, "%Z")
2859 2857
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
20 20 # XXX(gb) First run all the _Pure tests, then all the _Fast tests. You might
21 21 # not believe this, but in spite of all the sys.modules trickery running a _Pure
22 22 # test last will leave a mix of pure and native datetime stuff lying around.
23 -all_test_classes = []
23 +test_classes = []
24 24
25 25 for module, suffix in zip(test_modules, test_suffixes):
26 26 test_classes = []
@@ -34,8 +34,7 @@
34 34 test_classes.extend(type(test) for test in suit)
35 35 test_classes = sorted(set(test_classes), key=lambda cls: cls.__qualname__)
36 36 for cls in test_classes:
37 -cls.__name__ += suffix
38 -cls.__qualname__ += suffix
37 +cls.__name__ = name + suffix
39 38 @classmethod
40 39 def setUpClass(cls_, module=module):
41 40 cls_._save_sys_modules = sys.modules.copy()
@@ -48,10 +47,9 @@ def tearDownClass(cls_):
48 47 sys.modules.update(cls_._save_sys_modules)
49 48 cls.setUpClass = setUpClass
50 49 cls.tearDownClass = tearDownClass
51 -all_test_classes.extend(test_classes)
52 50
53 51 def test_main():
54 -run_unittest(*all_test_classes)
52 +run_unittest(*test_classes)
55 53
56 54 if __name__ == "__main__":
57 55 test_main()
Original file line number Diff line number Diff line change
@@ -1602,7 +1602,6 @@ Doobee R. Tzeck
1602 1602 Eren Türkay
1603 1603 Lionel Ulmer
1604 1604 Adnan Umer
1605 -Utkarsh Upadhyay
1606 1605 Roger Upole
1607 1606 Daniel Urban
1608 1607 Michael Urman