Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix tz toUTC intest_time test#133109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
StanFromIreland wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromStanFromIreland:time-test

Conversation

StanFromIreland
Copy link
Contributor

Currently on DST, this causes:

======================================================================FAIL: test_localtime_timezone (test.test_time.TestPytime.test_localtime_timezone)----------------------------------------------------------------------Traceback (most recent call last):  File "/home/stan/PycharmProjects/cpython/Lib/test/test_time.py", line 772, in test_localtime_timezone    self.assertEqual(lt.tm_gmtoff, -[time.timezone, time.altzone][lt.tm_isdst])    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^AssertionError: 3600 != 0----------------------------------------------------------------------Ran 63 tests in 2.938sFAILED (failures=1, skipped=3)test test_time failed0:00:02 load avg: 1.87 [1/1/1] test_time failed (1 failure)== Tests result: FAILURE ==1 test failed:    test_timeTotal duration: 3.0 secTotal tests: run=63 failures=1 skipped=3Total test files: run=1/1 failed=1Result: FAILURE

@serhiy-storchaka
Copy link
Member

It looks to me that the purpose of the test is to run on non-UTC timezone. It does not make sense to run it on UTC.

@StanFromIreland
Copy link
ContributorAuthor

It is buggy on most timezones. Seehttps://buildbot.python.org/#/builders/1678/builds/17 as an example (uses IST). It is not an inherently non-UTC test, I can freeze it to something else if there is another one guaranteed to work.

@pganssle
Copy link
Member

Shouldn't we solve this by making the test actually test that the desired behavior applies across all zones?

@StanFromIreland
Copy link
ContributorAuthor

solve this

Solving this forall time zones is unlikely.

As you said earlier:

So now it seems that there's no way to determine what the correct timezone offset and name are based on isdst.

I was looking into this over the last few days and was unable to find a nice solution either.

@serhiy-storchaka
Copy link
Member

This test was added in 2012 and was not changed since. If it fails, there is something wrong either with our code, or with platform. Please open an issue and provide as much details as possible. What platform, on what timezone the test fails.

@StanFromIreland
Copy link
ContributorAuthor

The issue (by Paul) has been open for a while#83985

@pganssle
Copy link
Member

I think that this issue only comes up in zones with negative DST, and it's hitting into a real bug. Fixing the test to UTC makes it seem like this test — which doesn't really do much in UTC, mind you — is not intended to work in other zones, which is the opposite of the truth.

This is the kind of thing that we would usexfail for if we were able to usepytest, though it's a bit tricky to define exactly where it fails. I think there are a couple of options here:

  1. Fix the underlying bug in some way
  2. Do something likexfail where you check for known failure conditions and affirmatively assert that the test is wrong (with a message to the effect that if that ever starts failing, we we should simply remove the "this test fails" assertion). This can probably be done withzoneinfo if you can figure out the system's TZID (assuming it has one), or possibly withdatetime, ifdatetime.astimezone() sets the result ofdst() to the correct thing (you just need to detect negative DST). Kinda tricky.
  3. Parameterize this test over a variety of fixed zones and times, and do thexfail thing for the ones where you know it is failing.

If we have a good way to parameterize over locale and to run these things with fixed times (a la freezegun), then I think option 3 is way better than option 2. It's a bit of a problem that this test will only fail during part of the year if run in a specific locale. Even if we fix the bug, ideally we'd have tests that always succeed or fail no matter what locale the test suite is run in.

(I realize I should probably know if we have a way to freeze time or parameterize over locales, but as you may have noticed by the delay in my responses to most things, my free time is extremely limited these days and it's been a while since I looked into the finer points of what's available in our test supports).

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@pgansslepganssleAwaiting requested review from pgansslepganssle is a code owner

@abalkinabalkinAwaiting requested review from abalkinabalkin is a code owner

Assignees
No one assigned
Labels
awaiting reviewtestsTests in the Lib/test dir
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@StanFromIreland@serhiy-storchaka@pganssle

[8]ページ先頭

©2009-2025 Movatter.jp