Skip to content

Commit

Permalink
fix: Flaky test_offline_mode__local_evaluation__correct_fallback (#103
Browse files Browse the repository at this point in the history
)
  • Loading branch information
khvn26 authored Aug 12, 2024
1 parent e1e0210 commit a2136d7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
- id: mypy
args: [--strict]
additional_dependencies:
[pydantic, pytest, pytest_mock, types-requests, flagsmith-flag-engine, responses, sseclient-py]
[freezegun, pydantic, pytest, pytest_mock, types-requests, flagsmith-flag-engine, responses, sseclient-py]
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
Expand Down
41 changes: 40 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pytest-mock = "^3.6.1"
pre-commit = "^2.17.0"
responses = "^0.24.1"
types-requests = "^2.32"
freezegun = "^1.5.1"

[tool.mypy]
plugins = ["pydantic.mypy"]
Expand Down
6 changes: 2 additions & 4 deletions tests/test_flagsmith.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import typing
import uuid

import freezegun
import pytest
import requests
import responses
Expand Down Expand Up @@ -527,6 +528,7 @@ def test_flagsmith_uses_offline_handler_if_set_and_no_api_response(


@responses.activate()
@freezegun.freeze_time()
def test_offline_mode__local_evaluation__correct_fallback(
mocker: MockerFixture,
environment_model: EnvironmentModel,
Expand All @@ -546,10 +548,6 @@ def test_offline_mode__local_evaluation__correct_fallback(
offline_handler=mock_offline_handler,
)

# We only verify local evaluation mode init phase here.
# Prevent additional API calls.
flagsmith.environment_data_polling_manager_thread.stop()

# When
environment_flags = flagsmith.get_environment_flags()
identity_flags = flagsmith.get_identity_flags("identity", traits={})
Expand Down

0 comments on commit a2136d7

Please sign in to comment.