Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Lib/test/datetimetester.py
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,6 @@ def test_strftime(self):
# bpo-41260: The parameter was named "fmt" in the pure python impl.
t.strftime(format="%f")

@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON; chrono fallback on Windows")
def test_strftime_trailing_percent(self):
# bpo-35066: Make sure trailing '%' doesn't cause datetime's strftime to
# complain. Different libcs have different handling of trailing
Expand Down
31 changes: 20 additions & 11 deletions Lib/test/test_strftime.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,21 @@ def _update_variables(self, now):
if now[3] < 12: self.ampm='(AM|am)'
else: self.ampm='(PM|pm)'

self.jan1 = time.localtime(time.mktime((now[0], 1, 1, 0, 0, 0, 0, 1, 0)))
jan1 = time.struct_time(
(
now.tm_year, # Year
1, # Month (January)
1, # Day (1st)
0, # Hour (0)
0, # Minute (0)
0, # Second (0)
-1, # tm_wday (will be determined)
1, # tm_yday (day 1 of the year)
-1, # tm_isdst (let the system determine)
)
)
# use mktime to get the correct tm_wday and tm_isdst values
self.jan1 = time.localtime(time.mktime(jan1))

try:
if now[8]: self.tz = time.tzname[1]
Expand All @@ -54,14 +68,10 @@ def _update_variables(self, now):
self.now = now

def setUp(self):
try:
import java
java.util.Locale.setDefault(java.util.Locale.US)
except ImportError:
from locale import setlocale, LC_TIME
saved_locale = setlocale(LC_TIME)
setlocale(LC_TIME, 'C')
self.addCleanup(setlocale, LC_TIME, saved_locale)
from locale import setlocale, LC_TIME
saved_locale = setlocale(LC_TIME)
setlocale(LC_TIME, 'C')
self.addCleanup(setlocale, LC_TIME, saved_locale)

def test_strftime(self):
now = time.time()
Expand Down Expand Up @@ -187,8 +197,7 @@ class Y1900Tests(unittest.TestCase):
def test_y_before_1900(self):
# Issue #13674, #19634
t = (1899, 1, 1, 0, 0, 0, 0, 0, 0)
if (sys.platform == "win32"
or sys.platform.startswith(("aix", "sunos", "solaris"))):
if sys.platform.startswith(("aix", "sunos", "solaris")):
with self.assertRaises(ValueError):
time.strftime("%y", t)
else:
Expand Down
40 changes: 2 additions & 38 deletions Lib/test/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ def test_strftime_invalid_format(self):
except ValueError as exc:
self.assertEqual(str(exc), 'Invalid format string')

# TODO: RUSTPYTHON; chrono fallback on Windows does not preserve surrogates
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
def test_strftime_special(self):
tt = time.gmtime(self.t)
s1 = time.strftime('%c', tt)
Expand Down Expand Up @@ -294,8 +292,6 @@ def _bounds_checking(self, func):
self.assertRaises(ValueError, func,
(1900, 1, 1, 0, 0, 0, 0, 367, -1))

# TODO: RUSTPYTHON; chrono on Windows rejects month=0/day=0 and raises wrong error type
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
def test_strftime_bounding_check(self):
self._bounds_checking(lambda tup: time.strftime('', tup))

Expand All @@ -312,8 +308,6 @@ def test_strftime_format_check(self):
except ValueError:
pass

# TODO: RUSTPYTHON; chrono on Windows does not handle month=0/day=0 in struct_time
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
def test_default_values_for_zero(self):
# Make sure that using all zeros uses the proper default
# values. No test for daylight savings since strftime() does
Expand All @@ -324,8 +318,6 @@ def test_default_values_for_zero(self):
result = time.strftime("%Y %m %d %H %M %S %w %j", (2000,)+(0,)*8)
self.assertEqual(expected, result)

# TODO: RUSTPYTHON; chrono %Z on Windows not compatible with strptime
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
@skip_if_buggy_ucrt_strfptime
def test_strptime(self):
# Should be able to go round-trip from strftime to strptime without
Expand Down Expand Up @@ -382,13 +374,9 @@ def test_asctime(self):
self.assertRaises(TypeError, time.asctime, ())
self.assertRaises(TypeError, time.asctime, (0,) * 10)

# TODO: RUSTPYTHON; chrono on Windows rejects month=0/day=0
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
def test_asctime_bounding_check(self):
self._bounds_checking(time.asctime)

# TODO: RUSTPYTHON; chrono on Windows formats negative years differently
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
def test_ctime(self):
t = time.mktime((1973, 9, 16, 1, 3, 52, 0, 0, -1))
self.assertEqual(time.ctime(t), 'Sun Sep 16 01:03:52 1973')
Expand Down Expand Up @@ -761,37 +749,13 @@ def test_negative(self):


class TestAsctime4dyear(_TestAsctimeYear, _Test4dYear, unittest.TestCase):
# TODO: RUSTPYTHON; chrono on Windows cannot handle month=0/day=0 in struct_time
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
def test_year(self, *args, **kwargs):
return super().test_year(*args, **kwargs)

@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
def test_large_year(self):
return super().test_large_year()

@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
def test_negative(self):
return super().test_negative()
pass

class TestStrftime4dyear(_TestStrftimeYear, _Test4dYear, unittest.TestCase):
# TODO: RUSTPYTHON; chrono on Windows cannot handle month=0/day=0 in struct_time
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
def test_year(self, *args, **kwargs):
return super().test_year(*args, **kwargs)

@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
def test_large_year(self):
return super().test_large_year()

@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
def test_negative(self):
return super().test_negative()
pass


class TestPytime(unittest.TestCase):
# TODO: RUSTPYTHON; chrono %Z on Windows gives offset instead of timezone name
@unittest.expectedFailureIf(sys.platform == "win32", "TODO: RUSTPYTHON")
@skip_if_buggy_ucrt_strfptime
@unittest.skipUnless(time._STRUCT_TM_ITEMS == 11, "needs tm_zone support")
def test_localtime_timezone(self):
Expand Down
Loading
Loading