`test_environment_does_not_update_on_past_event` is flaky

Đang mở
#187 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
50/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
testing

Hướng nghiên cứu

Bắt đầu với tests/test_streaming_manager.py và chạy test_environment_does_not_update_on_past_event trên Python 3.10 để tái hiện lỗi không liên tục. Kiểm tra Flagsmith.handle_stream_event và các lệnh gọi update_environment được mô phỏng; công việc được xem là hoàn tất khi một StreamEvent trong quá khứ không gọi update_environment và các bài kiểm thử của trình quản lý streaming luôn vượt qua ổn định.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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 =========================
Ngôn ngữ chính
Python
Star
24
Fork
12
Merge trung bình
15 giờ 43 phút
Pull request đã merge (30 ngày)
4

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Flagsmith/flagsmith-python-client

Tất cả issue của Flagsmith/flagsmith-python-client

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.