Description
Bug report
Bug description:
This is not a duplicate of other IST related issues, this is just a bug in the test itself from a quick look. After further investigation it appears this is indeed just a IST bug but the test also calculates it wrong.
From buildbot run (on IST):
======================================================================
FAIL: test_strftime (test.test_strftime.StrftimeTest.test_strftime)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/stan/buildarea/3.x.stan-raspbian/build/Lib/test/test_strftime.py", line 65, in test_strftime
self.strftest1(now)
~~~~~~~~~~~~~~^^^^^
File "/home/stan/buildarea/3.x.stan-raspbian/build/Lib/test/test_strftime.py", line 124, in strftest1
self.fail("Conflict for %s (%s): expected %s, but got %s"
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
% (e[0], e[2], e[1], result))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Conflict for %W (week number of the year (Mon 1st)): expected 18, but got 19
Stdout:
strftime test for Mon May 12 18:08:48 2025
----------------------------------------------------------------------
Ran 4 tests in 0.049s
It seems both the expected and returned are wrong, according to this website it should be week 20. Week 0 is days before the first week, so it would exist in our case, if it is counted, then the returned value is correct, but the test is wrong. Test passes in UTC however.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Projects
Status
Activity
GGyll commentedon May 19, 2025
As per the docs for time:
https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior
So you can say the week number is 0-indexed since the first week of the year is 0. Although I think the wording makes it confusing, especially since datetime.datetime.now().isocalendar() returns 21
Regarding the test failing on IST, I was not able to reproduce this issue, I tried mocking IST time and got 20 both as expected value and the output (as per today May 19th, 2025). Perhaps this could be an issue regarding ISO 8601 Standard calculating week number by Thursdays, and the US system calculating by number of Sundays?
StanFromIreland commentedon May 19, 2025
Just to check, you used
Irish Standard Time
and notIndian Standard Time
?On my machine:
GGyll commentedon May 19, 2025
I tried with Indian, now with Irish and it fails.. looking into this now
gh-133940: test_strftime incorrectly calculates expected week (GH-134281
pythongh-133940: test_strftime incorrectly calculates expected week (p…
gpshead commentedon May 20, 2025
Thanks for the contribution!
4 remaining items