-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Update unit tests for non-UTC windows environments #11265
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@sbidoul I'm happy if either fix ends up getting meged. |
This PR has a smaller diff so it's more attractive to lazy reviewers :) @finnagin maybe we can drop the |
@sbidoul Sure! |
@sbidoul I've removed the I also went ahead and ran it locally as well as in a different branch with a modified github actions workflow to try a different timezone in the Linux, MacOS, & Windows environments and it passed the tests there as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Some of the unit tests seem to fail when run on some windows environments that are not configured with the UTC timezone. I believe this may be due to
time.tzset()
not being implemented in windows and so this code does not get run in conftest.py during the tests causing the time zone to not be updated.I've tested this on two different machines, one running Windows 10 and the other running Windows 11. In both cases I used python 3.10, set the time zone to something other than UTC, and run the tests using nox (version 2022.1.7) with the following command:
nox -s test-3.10 -- -m unit -n auto
. This resulted the the following failing tests:All tests seem to be failing due to the time stamp in the log file being wrong. For example, the error I get from
test_log_command_success
when my time zone is set to PST is:Which is off by the 8 hour difference between PST and UTC. When I changed my system's time zone to UTC in both cases the tests then pass.
My proposed fix is to add the value
time.timezone
to the fixed time values in bothtest_base_command.py
andtest_logging.py
. In the cases where the timezone was correctly set to UTC this value will be 0 and thus not change fixed time value. However, in the cases where the timezone was not correctly set to UTC this value will be non-zero and update the test's fixed time value to match the time as if it were in UTC.fixes #10816
closes #10834
closes #10835