diff --git a/news/fd5122d3-031e-4b12-9a68-dea494e22fe3.trivial.rst b/news/fd5122d3-031e-4b12-9a68-dea494e22fe3.trivial.rst new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/conftest.py b/tests/conftest.py index 1cf058d7000..210ff0f4e8a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,7 +6,6 @@ import shutil import subprocess import sys -import time from contextlib import ExitStack, contextmanager from pathlib import Path from typing import ( @@ -658,16 +657,6 @@ def mock_server() -> Iterator[MockServer]: yield test_server -@pytest.fixture -def utc() -> Iterator[None]: - # time.tzset() is not implemented on some platforms, e.g. Windows. - tzset = getattr(time, "tzset", lambda: None) - with patch.dict(os.environ, {"TZ": "UTC"}): - tzset() - yield - tzset() - - @pytest.fixture def proxy(request: pytest.FixtureRequest) -> str: return request.config.getoption("proxy") diff --git a/tests/unit/test_base_command.py b/tests/unit/test_base_command.py index 6bdc5ecc361..71a50fca617 100644 --- a/tests/unit/test_base_command.py +++ b/tests/unit/test_base_command.py @@ -1,5 +1,6 @@ import logging import os +import time from optparse import Values from pathlib import Path from typing import Callable, Iterator, List, NoReturn, Optional @@ -15,8 +16,8 @@ @pytest.fixture -def fixed_time(utc: None) -> Iterator[None]: - with patch("time.time", lambda: 1547704837.040001): +def fixed_time() -> Iterator[None]: + with patch("time.time", lambda: 1547704837.040001 + time.timezone): yield diff --git a/tests/unit/test_logging.py b/tests/unit/test_logging.py index 4f0447931dd..3ba6ed57ca5 100644 --- a/tests/unit/test_logging.py +++ b/tests/unit/test_logging.py @@ -1,4 +1,5 @@ import logging +import time from threading import Thread from unittest.mock import patch @@ -22,7 +23,7 @@ def make_record(self, msg: str, level_name: str) -> logging.LogRecord: level_number = getattr(logging, level_name) attrs = dict( msg=msg, - created=1547704837.040001, + created=1547704837.040001 + time.timezone, msecs=40, levelname=level_name, levelno=level_number, @@ -41,7 +42,7 @@ def make_record(self, msg: str, level_name: str) -> logging.LogRecord: ("CRITICAL", "ERROR: hello\nworld"), ], ) - def test_format(self, level_name: str, expected: str, utc: None) -> None: + def test_format(self, level_name: str, expected: str) -> None: """ Args: level_name: a logging level name (e.g. "WARNING"). @@ -61,9 +62,7 @@ def test_format(self, level_name: str, expected: str, utc: None) -> None: ), ], ) - def test_format_with_timestamp( - self, level_name: str, expected: str, utc: None - ) -> None: + def test_format_with_timestamp(self, level_name: str, expected: str) -> None: record = self.make_record("hello\nworld", level_name=level_name) f = IndentingFormatter(fmt="%(message)s", add_timestamp=True) assert f.format(record) == expected @@ -76,7 +75,7 @@ def test_format_with_timestamp( ("CRITICAL", "DEPRECATION: hello\nworld"), ], ) - def test_format_deprecated(self, level_name: str, expected: str, utc: None) -> None: + def test_format_deprecated(self, level_name: str, expected: str) -> None: """ Test that logged deprecation warnings coming from deprecated() don't get another prefix. @@ -88,7 +87,7 @@ def test_format_deprecated(self, level_name: str, expected: str, utc: None) -> N f = IndentingFormatter(fmt="%(message)s") assert f.format(record) == expected - def test_thread_safety_base(self, utc: None) -> None: + def test_thread_safety_base(self) -> None: record = self.make_record( "DEPRECATION: hello\nworld", level_name="WARNING", @@ -105,7 +104,7 @@ def thread_function() -> None: thread.join() assert results[0] == results[1] - def test_thread_safety_indent_log(self, utc: None) -> None: + def test_thread_safety_indent_log(self) -> None: record = self.make_record( "DEPRECATION: hello\nworld", level_name="WARNING",