Skip to content

Commit 74c73b4

Browse files
authored
fix(tests): Inaccuratefreeze_time for a certain timestamp (#63)
1 parent 49268aa commit 74c73b4

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

tests/unit/common/core/test_logging.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import json
22
import logging
3-
import logging.config
43
import os
54

65
import pytest
76

87
from common.core.logging import JsonFormatter
98

109

11-
@pytest.mark.freeze_time("2023-12-08T06:05:47.320000+00:00")
10+
@pytest.mark.freeze_time("2023-12-08T06:05:47+00:00")
1211
def test_json_formatter__outputs_expected(
1312
caplog: pytest.LogCaptureFixture,
1413
request: pytest.FixtureRequest,
@@ -25,7 +24,7 @@ def test_json_formatter__outputs_expected(
2524
expected_tb_string = (
2625
"Traceback (most recent call last):\n"
2726
f' File "{expected_module_path}",'
28-
" line 34, in _log_traceback\n"
27+
" line 33, in _log_traceback\n"
2928
" raise Exception()\nException"
3029
)
3130

@@ -44,15 +43,15 @@ def _log_traceback() -> None:
4443
{
4544
"levelname": "INFO",
4645
"message": "hello arg1, 22",
47-
"timestamp": "2023-12-08 06:05:47,319",
46+
"timestamp": "2023-12-08 06:05:47,000",
4847
"logger_name": "test_json_formatter__outputs_expected",
4948
"pid": expected_pid,
5049
"thread_name": "MainThread",
5150
},
5251
{
5352
"levelname": "ERROR",
5453
"message": "this is an error",
55-
"timestamp": "2023-12-08 06:05:47,319",
54+
"timestamp": "2023-12-08 06:05:47,000",
5655
"logger_name": "test_json_formatter__outputs_expected",
5756
"pid": expected_pid,
5857
"thread_name": "MainThread",

tests/unit/common/gunicorn/test_logging.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from common.test_tools import AssertMetricFixture
1717

1818

19-
@pytest.mark.freeze_time("2023-12-08T06:05:47.320000+00:00")
19+
@pytest.mark.freeze_time("2023-12-08T06:05:47+00:00")
2020
def test_gunicorn_access_log_json_formatter__outputs_expected(
2121
settings: SettingsWrapper,
2222
) -> None:
@@ -55,7 +55,7 @@ def test_gunicorn_access_log_json_formatter__outputs_expected(
5555
"r": "GET",
5656
"s": 200,
5757
"T": 1,
58-
"t": datetime.fromisoformat("2023-12-08T06:05:47.320000+00:00").strftime(
58+
"t": datetime.fromisoformat("2023-12-08T06:05:47+00:00").strftime(
5959
"[%d/%b/%Y:%H:%M:%S %z]"
6060
),
6161
"u": "-",
@@ -92,7 +92,7 @@ def test_gunicorn_access_log_json_formatter__outputs_expected(
9292
"status": "200",
9393
"thread_name": "MainThread",
9494
"time": "2023-12-08T06:05:47+00:00",
95-
"timestamp": "2023-12-08 06:05:47,319",
95+
"timestamp": "2023-12-08 06:05:47,000",
9696
"user_agent": "requests",
9797
}
9898

0 commit comments

Comments
 (0)