`test_environment_does_not_update_on_past_event` is flaky
还没有人认领这个 Issue。
评估
调研方向
从 tests/test_streaming_manager.py 开始,并在 Python 3.10 下运行 test_environment_does_not_update_on_past_event,以复现间歇性失败。检查 Flagsmith.handle_stream_event 和模拟的 update_environment 调用;当过去的 StreamEvent 不调用 update_environment 且 streaming manager 测试能够稳定通过时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
The following test is failing sometimes for Python 3.10:
============================= test session starts ==============================
platform linux -- Python 3.10.19, pytest-7.4.4, pluggy-1.5.0
rootdir: /home/runner/work/flagsmith-python-client/flagsmith-python-client
plugins: mock-3.14.1, cov-4.1.0, pyfakefs-5.9.2
collected 73 items
tests/test_analytics.py ..... [ 6%]
tests/test_flagsmith.py ........................................... [ 65%]
tests/test_models.py ............ [ 82%]
tests/test_offline_handlers.py .. [ 84%]
tests/test_polling_manager.py .... [ 90%]
tests/test_streaming_manager.py ..F. [ 95%]
tests/test_webhooks.py ... [100%]
=================================== FAILURES ===================================
________________ test_environment_does_not_update_on_past_event ________________
self = <MagicMock name='update_environment' id='140607846335680'>
def assert_not_called(self):
"""assert that the mock was never called.
"""
if self.call_count != 0:
msg = ("Expected '%s' to not have been called. Called %s times.%s"
% (self._mock_name or 'mock',
self.call_count,
self._calls_repr()))
> raise AssertionError(msg)
E AssertionError: Expected 'update_environment' to not have been called. Called 2 times.
E Calls: [call(), call()].
/opt/hostedtoolcache/Python/3.10.19/x64/lib/python3.10/unittest/mock.py:890: AssertionError
During handling of the above exception, another exception occurred:
server_api_key = 'ser.ZnjtUuLXOhrkpIQbVTJR'
mocker = <pytest_mock.plugin.MockerFixture object at 0x7fe1d0bbc340>
def test_environment_does_not_update_on_past_event(
server_api_key: str, mocker: MockerFixture
) -> None:
stream_updated_at = datetime(2020, 1, 1, 1, 1, 1, tzinfo=timezone.utc)
environment_updated_at = datetime(2020, 1, 1, 1, 1, 2, tzinfo=timezone.utc)
mocker.patch("flagsmith.Flagsmith.update_environment")
flagsmith = Flagsmith(environment_key=server_api_key)
flagsmith._evaluation_context = MagicMock()
flagsmith._environment_updated_at = environment_updated_at
flagsmith.handle_stream_event(event=StreamEvent(updated_at=stream_updated_at))
assert isinstance(flagsmith.update_environment, Mock)
> flagsmith.update_environment.assert_not_called()
E AssertionError: Expected 'update_environment' to not have been called. Called 2 times.
E Calls: [call(), call()].
tests/test_streaming_manager.py:68: AssertionError
=========================== short test summary info ============================
FAILED tests/test_streaming_manager.py::test_environment_does_not_update_on_past_event - AssertionError: Expected 'update_environment' to not have been called. Called 2 times.
Calls: [call(), call()].
========================= 1 failed, 72 passed in 0.80s =========================
- 主要语言
- Python
- 星标
- 24
- 派生
- 12
- 平均合并
- 15 小时 43 分钟
- 30 天内合并 PR
- 4
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Flagsmith/flagsmith-python-client 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 68/100
-
难度 3/5 1-2 天 新手友好度 65/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 68/100
-
Flagsmith/flagsmith-python-client#198 · 1 条评论 · 已指派 2 人 ·
查看 Flagsmith/flagsmith-python-client 的全部 Issue
相似的 Issue
-
bug ci good first issue
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 76/100
-
documentation
难度 2/5 半天 新手友好度 62/100
inmanta/inmanta-core#10835 ·
-
sponsored
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 86/100
Diaoul/subliminal#1382 ·