pywin32 icon indicating copy to clipboard operation
pywin32 copied to clipboard

pywin32_testall.py timezone tests fails in non American regional settings machine

Open csrabak opened this issue 2 years ago • 3 comments

  • Expected behavior and actual behavior.

The tests are expected to go green, but fail due the locale (and time zone) are different from the designed for the tests?

For example:

File "C:\Python\Python311\Lib\site-packages\win32\lib\win32timezone.py", line 22, in win32timezone Failed example: assert 'Mountain Standard Time' in win32timezone.TimeZoneInfo.get_sorted_time_zone_names() Exception raised: Traceback (most recent call last): File "C:\Python\Python311\Lib\doctest.py", line 1351, in __run exec(compile(example.source, filename, "single", File "<doctest win32timezone[1]>", line 1, in assert 'Mountain Standard Time' in win32timezone.TimeZoneInfo.get_sorted_time_zone_names() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError


File "C:\Python\Python311\Lib\site-packages\win32\lib\win32timezone.py", line 58, in win32timezone Failed example: str(est.displayName) Expected: '(UTC-05:00) Eastern Time (US & Canada)' Got: '(UTC-05:00) Hora Oriental (EUA e Canadá)'


  • Steps to reproduce the problem.

C:\Python\Python311>py Scripts\pywin32_testall.py

  • Version of Python and pywin32 Python 3.11.4 pywin32 Release 306

csrabak avatar Jul 17 '23 20:07 csrabak

It works for me in Australia, so I suspect the problem is the locale and not the specific timezone.

mhammond avatar Jul 17 '23 22:07 mhammond

I undertand your comment as the locale triggers the problem, which I concur plainly, as the expression of the assertion is in English and the returned one is in Portuguese.

I did not dig into the source code to understand, but for me is a puzzle, why would the script get the timezone in English and collect it in the locale language. . .

I surmize that the script changes the timezone for the sake of the test, as when the run (above) generated the results, the machine wasn't in UTC-5 but UTC-3.

Perhaps the test should ascertain the locale (or language for the collection of the string) be always English?

HTH

csrabak avatar Jul 18 '23 20:07 csrabak

I'm also having issues with timezone realted test locally:

File "C:\Users\Avasam\AppData\Local\Programs\Python\Python310\lib\site-packages\win32\lib\win32timezone.py", line 682, in win32timezone.TimeZoneInfo.tzname
Failed example:
    MST.tzname(datetime.datetime(2003, 8, 2))
Expected:
    'Mountain Daylight Time'
Got:
    'Mountain Summer Time'
**********************************************************************
1 items had failures:
   1 of   4 in win32timezone.TimeZoneInfo.tzname

Avasam avatar Apr 17 '25 16:04 Avasam