Blame SOURCES/0001-Workaround-the-issues-with-hypothesis-6.6.patch

rdobuilder a5b753
From 0646279dab694a89562846c810202ce2c0b49be3 Mon Sep 17 00:00:00 2001
rdobuilder a5b753
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
rdobuilder a5b753
Date: Mon, 8 Mar 2021 19:16:26 +0100
rdobuilder a5b753
Subject: [PATCH] Workaround the issues with hypothesis 6.6
rdobuilder a5b753
rdobuilder a5b753
Hypothesis 6.6 will produce:
rdobuilder a5b753
rdobuilder a5b753
    E  hypothesis.errors.FailedHealthCheck: test/test_flow_control_window.py::TestAutomaticFlowControl::test_mixing_update_forms uses the 'frame_factory' fixture, which is reset between function calls but not between test cases generated by `@given(...)`.  You can change it to a module- or session-scoped fixture if it is safe to reuse; if not we recommend using a context manager inside your test function.  See https://docs.pytest.org/en/latest/fixture.html#sharing-test-data for details on fixture scope.
rdobuilder a5b753
    E  See https://hypothesis.readthedocs.io/en/latest/healthchecks.html for more information about this. If you want to disable just this health check, add HealthCheck.function_scoped_fixture to the suppress_health_check settings for this test.
rdobuilder a5b753
rdobuilder a5b753
Since the tests already workaround the problem,
rdobuilder a5b753
acknowledging https://github.com/HypothesisWorks/hypothesis-python/issues/377,
rdobuilder a5b753
we can safely disable the check.
rdobuilder a5b753
rdobuilder a5b753
Hypothesis 5.49 introduced the function_scoped_fixture health check value,
rdobuilder a5b753
hence it is now the lowest required version of hypothesis.
rdobuilder a5b753
---
rdobuilder a5b753
 test/test_basic_logic.py         | 3 ++-
rdobuilder a5b753
 test/test_flow_control_window.py | 7 ++++++-
rdobuilder a5b753
 tox.ini                          | 2 +-
rdobuilder a5b753
 3 files changed, 9 insertions(+), 3 deletions(-)
rdobuilder a5b753
rdobuilder a5b753
diff --git a/test/test_basic_logic.py b/test/test_basic_logic.py
rdobuilder a5b753
index fb54fe50..8c8f3b7d 100644
rdobuilder a5b753
--- a/test/test_basic_logic.py
rdobuilder a5b753
+++ b/test/test_basic_logic.py
rdobuilder a5b753
@@ -21,7 +21,7 @@
rdobuilder a5b753
 
rdobuilder a5b753
 from . import helpers
rdobuilder a5b753
 
rdobuilder a5b753
-from hypothesis import given
rdobuilder a5b753
+from hypothesis import given, settings, HealthCheck
rdobuilder a5b753
 from hypothesis.strategies import integers
rdobuilder a5b753
 
rdobuilder a5b753
 
rdobuilder a5b753
@@ -790,6 +790,7 @@ def test_headers_are_lowercase(self, frame_factory):
rdobuilder a5b753
         assert c.data_to_send() == expected_frame.serialize()
rdobuilder a5b753
 
rdobuilder a5b753
     @given(frame_size=integers(min_value=2**14, max_value=(2**24 - 1)))
rdobuilder a5b753
+    @settings(suppress_health_check=[HealthCheck.function_scoped_fixture])
rdobuilder a5b753
     def test_changing_max_frame_size(self, frame_factory, frame_size):
rdobuilder a5b753
         """
rdobuilder a5b753
         When the user changes the max frame size and the change is ACKed, the
rdobuilder a5b753
diff --git a/test/test_flow_control_window.py b/test/test_flow_control_window.py
rdobuilder a5b753
index 24b345aa..7a445af1 100644
rdobuilder a5b753
--- a/test/test_flow_control_window.py
rdobuilder a5b753
+++ b/test/test_flow_control_window.py
rdobuilder a5b753
@@ -7,7 +7,7 @@
rdobuilder a5b753
 """
rdobuilder a5b753
 import pytest
rdobuilder a5b753
 
rdobuilder a5b753
-from hypothesis import given
rdobuilder a5b753
+from hypothesis import given, settings, HealthCheck
rdobuilder a5b753
 from hypothesis.strategies import integers
rdobuilder a5b753
 
rdobuilder a5b753
 import h2.config
rdobuilder a5b753
@@ -715,6 +715,7 @@ def _setup_connection_and_send_headers(self, frame_factory):
rdobuilder a5b753
         return c
rdobuilder a5b753
 
rdobuilder a5b753
     @given(stream_id=integers(max_value=0))
rdobuilder a5b753
+    @settings(suppress_health_check=[HealthCheck.function_scoped_fixture])
rdobuilder a5b753
     def test_must_acknowledge_for_stream(self, frame_factory, stream_id):
rdobuilder a5b753
         """
rdobuilder a5b753
         Flow control acknowledgements must be done on a stream ID that is
rdobuilder a5b753
@@ -740,6 +741,7 @@ def test_must_acknowledge_for_stream(self, frame_factory, stream_id):
rdobuilder a5b753
             )
rdobuilder a5b753
 
rdobuilder a5b753
     @given(size=integers(max_value=-1))
rdobuilder a5b753
+    @settings(suppress_health_check=[HealthCheck.function_scoped_fixture])
rdobuilder a5b753
     def test_cannot_acknowledge_less_than_zero(self, frame_factory, size):
rdobuilder a5b753
         """
rdobuilder a5b753
         The user must acknowledge at least 0 bytes.
rdobuilder a5b753
@@ -837,6 +839,7 @@ def test_acknowledging_streams_we_never_saw(self, frame_factory):
rdobuilder a5b753
             c.acknowledge_received_data(2048, stream_id=101)
rdobuilder a5b753
 
rdobuilder a5b753
     @given(integers(min_value=1025, max_value=DEFAULT_FLOW_WINDOW))
rdobuilder a5b753
+    @settings(suppress_health_check=[HealthCheck.function_scoped_fixture])
rdobuilder a5b753
     def test_acknowledging_1024_bytes_when_empty_increments(self,
rdobuilder a5b753
                                                             frame_factory,
rdobuilder a5b753
                                                             increment):
rdobuilder a5b753
@@ -873,6 +876,7 @@ def test_acknowledging_1024_bytes_when_empty_increments(self,
rdobuilder a5b753
     # This test needs to use a lower cap, because otherwise the algo will
rdobuilder a5b753
     # increment the stream window anyway.
rdobuilder a5b753
     @given(integers(min_value=1025, max_value=(DEFAULT_FLOW_WINDOW // 4) - 1))
rdobuilder a5b753
+    @settings(suppress_health_check=[HealthCheck.function_scoped_fixture])
rdobuilder a5b753
     def test_connection_only_empty(self, frame_factory, increment):
rdobuilder a5b753
         """
rdobuilder a5b753
         If the connection flow control window is empty, but the stream flow
rdobuilder a5b753
@@ -916,6 +920,7 @@ def test_connection_only_empty(self, frame_factory, increment):
rdobuilder a5b753
         assert c.data_to_send() == expected_data
rdobuilder a5b753
 
rdobuilder a5b753
     @given(integers(min_value=1025, max_value=DEFAULT_FLOW_WINDOW))
rdobuilder a5b753
+    @settings(suppress_health_check=[HealthCheck.function_scoped_fixture])
rdobuilder a5b753
     def test_mixing_update_forms(self, frame_factory, increment):
rdobuilder a5b753
         """
rdobuilder a5b753
         If the user mixes ackowledging data with manually incrementing windows,
rdobuilder a5b753
diff --git a/tox.ini b/tox.ini
rdobuilder a5b753
index 69291df6..1f5e538b 100644
rdobuilder a5b753
--- a/tox.ini
rdobuilder a5b753
+++ b/tox.ini
rdobuilder a5b753
@@ -15,7 +15,7 @@ deps =
rdobuilder a5b753
     pytest==6.0.2
rdobuilder a5b753
     pytest-cov==2.10.1
rdobuilder a5b753
     pytest-xdist==2.1.0
rdobuilder a5b753
-    hypothesis>=5.5,<6
rdobuilder a5b753
+    hypothesis>=5.49,<7
rdobuilder a5b753
 commands =
rdobuilder a5b753
     pytest --cov-report=xml  --cov-report=term --cov=h2 {posargs}
rdobuilder a5b753