Some unit tests are sensitive to Timezone of host machine
See original GitHub issueDescription
Running the pip unit tests on Windows in (UTC-5:00) Eastern (US & Canada):
- nox -s test-3.7 – -m unit --verbose --numprocesses auto --showlocals
I get a handful of FAILEDs, however if I change the hosts timezone to UTC I get 5 less FAILEDs, specifically this set of tests:
FAILED tests/unit/test_base_command.py::test_log_file_command_error - assert False
FAILED tests/unit/test_base_command.py::test_log_command_error - assert False
FAILED tests/unit/test_base_command.py::test_log_command_success - AssertionError: assert '2019-01-17T01:00:37,040 fake' == '2019-01-17T06:00:37,040 fake'
FAILED tests/unit/test_logging.py::TestIndentingFormatter::test_format_with_timestamp[INFO-2019-01-17T06:00:37,040 hello\n2019-01-17T06:00:37,040 world] - As...
FAILED tests/unit/test_logging.py::TestIndentingFormatter::test_format_with_timestamp[WARNING-2019-01-17T06:00:37,040 WARNING: hello\n2019-01-17T06:00:37,040 world]
Expected behavior
Shouldn’t need to change timezone to run pip tests locally?
pip version
22
Python version
3.7.9
OS
Windows 10
How to Reproduce
Above
Output
No response
Code of Conduct
- I agree to follow the PSF Code of Conduct.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Override Java System.currentTimeMillis for testing time ...
True time, different time zone. You can control which time zone is assigned by the Clock implementation. This might be useful in some...
Read more >A Simple Guide for Testing DateTime - Mudbath
Here are some top tips for your timezone unit tests! ... Do not create datetimes relative to the machine's timezone, but expect datetimes ......
Read more >Abstracting System Time in ASP.NET Applications - Simple Talk
Right--UtcNow is absolute time; Now is not and depends on the timezone configured on the server. But when the application is sensitive to...
Read more >Timekeeping in VMware Virtual Machines
The virtual machine checks for pending virtual timer interrupts only at certain points, such as when the underlying hardware receives a physical timer...
Read more >Testing best practices - GitLab Docs
GitLab development guidelines - testing best practices. ... Fast unit tests ... Any test that exercises or verifies something time-sensitive should make use ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Unless someone else is very motivated to fix these I’m happy to try and make a PR this weekend, give me a chance to learn a bit more about tests. I’ll update back here with my progress if I run in to an issue I can’t fix.