Skip to content

Commit e62922c

Browse files
committed
[3.5] bpo-30822: Fix testing of datetime module. (pythonGH-2530)
Only C implementation was tested.. (cherry picked from commit 98b6bc3)
1 parent 0b12107 commit e62922c

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

Lib/datetime.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2135,7 +2135,8 @@ def _name_from_offset(delta):
21352135
_check_tzinfo_arg, _check_tzname, _check_utc_offset, _cmp, _cmperror,
21362136
_date_class, _days_before_month, _days_before_year, _days_in_month,
21372137
_format_time, _is_leap, _isoweek1monday, _math, _ord2ymd,
2138-
_time, _time_class, _tzinfo_class, _wrap_strftime, _ymd2ord)
2138+
_time, _time_class, _tzinfo_class, _wrap_strftime, _ymd2ord,
2139+
_divide_and_round)
21392140
# XXX Since import * above excludes names that start with _,
21402141
# docstring does not get overwritten. In the future, it may be
21412142
# appropriate to maintain a single module level docstring and

Lib/test/datetimetester.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ def test_constants(self):
5353
self.assertEqual(datetime.MAXYEAR, 9999)
5454

5555
def test_name_cleanup(self):
56-
if '_Fast' not in str(self):
57-
return
56+
if '_Pure' in self.__class__.__name__:
57+
self.skipTest('Only run for Fast C implementation')
58+
5859
datetime = datetime_module
5960
names = set(name for name in dir(datetime)
6061
if not name.startswith('__') and not name.endswith('__'))
@@ -64,8 +65,9 @@ def test_name_cleanup(self):
6465
self.assertEqual(names - allowed, set([]))
6566

6667
def test_divide_and_round(self):
67-
if '_Fast' in str(self):
68-
return
68+
if '_Fast' in self.__class__.__name__:
69+
self.skipTest('Only run for Pure Python implementation')
70+
6971
dar = datetime_module._divide_and_round
7072

7173
self.assertEqual(dar(-10, -3), 3)
@@ -2733,7 +2735,7 @@ def tzname(self, dt): return self.tz
27332735
self.assertRaises(TypeError, t.strftime, "%Z")
27342736

27352737
# Issue #6697:
2736-
if '_Fast' in str(self):
2738+
if '_Fast' in self.__class__.__name__:
27372739
Badtzname.tz = '\ud800'
27382740
self.assertRaises(ValueError, t.strftime, "%Z")
27392741

Lib/test/test_datetime.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
for name, cls in module.__dict__.items():
2727
if not (isinstance(cls, type) and issubclass(cls, unittest.TestCase)):
2828
continue
29-
cls.__name__ = name + suffix
29+
cls.__name__ += suffix
30+
cls.__qualname__ += suffix
3031
@classmethod
3132
def setUpClass(cls_, module=module):
3233
cls_._save_sys_modules = sys.modules.copy()

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,7 @@ Doobee R. Tzeck
15451545
Eren Türkay
15461546
Lionel Ulmer
15471547
Adnan Umer
1548+
Utkarsh Upadhyay
15481549
Roger Upole
15491550
Daniel Urban
15501551
Michael Urman

0 commit comments

Comments
 (0)