Skip to content

Commit a2136d7

Browse files
authored
fix: Flaky test_offline_mode__local_evaluation__correct_fallback (#103)
1 parent e1e0210 commit a2136d7

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ repos:
55
- id: mypy
66
args: [--strict]
77
additional_dependencies:
8-
[pydantic, pytest, pytest_mock, types-requests, flagsmith-flag-engine, responses, sseclient-py]
8+
[freezegun, pydantic, pytest, pytest_mock, types-requests, flagsmith-flag-engine, responses, sseclient-py]
99
- repo: https://github.com/PyCQA/isort
1010
rev: 5.13.2
1111
hooks:

poetry.lock

Lines changed: 40 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pytest-mock = "^3.6.1"
2727
pre-commit = "^2.17.0"
2828
responses = "^0.24.1"
2929
types-requests = "^2.32"
30+
freezegun = "^1.5.1"
3031

3132
[tool.mypy]
3233
plugins = ["pydantic.mypy"]

tests/test_flagsmith.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import typing
44
import uuid
55

6+
import freezegun
67
import pytest
78
import requests
89
import responses
@@ -527,6 +528,7 @@ def test_flagsmith_uses_offline_handler_if_set_and_no_api_response(
527528

528529

529530
@responses.activate()
531+
@freezegun.freeze_time()
530532
def test_offline_mode__local_evaluation__correct_fallback(
531533
mocker: MockerFixture,
532534
environment_model: EnvironmentModel,
@@ -546,10 +548,6 @@ def test_offline_mode__local_evaluation__correct_fallback(
546548
offline_handler=mock_offline_handler,
547549
)
548550

549-
# We only verify local evaluation mode init phase here.
550-
# Prevent additional API calls.
551-
flagsmith.environment_data_polling_manager_thread.stop()
552-
553551
# When
554552
environment_flags = flagsmith.get_environment_flags()
555553
identity_flags = flagsmith.get_identity_flags("identity", traits={})

0 commit comments

Comments
 (0)