From 606974f2c9a51488224201c3f7f7dcf169330441 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 14 Jul 2026 14:31:20 +0000 Subject: [PATCH 1/2] Run tests/ (not just tests/unit) in CI and stabilize strategy tests The CI test step ran `pytest test_functions.py tests/unit`, which never collected tests/test_strategies.py (it lives in tests/, one level up). As a result the hypothesis version-strategy tests were never exercised in CI. Point the test step at `tests` so they run, and suppress HealthCheck.too_slow on the TestVersionStrategy cases: the `version` composite is legitimately slow to generate for large digit counts and otherwise trips Hypothesis' input-generation health check intermittently. Refs #263 Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01AQqEBHkvu6QDaidS4zYPVs --- .github/workflows/test.yml | 2 +- tests/test_strategies.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index de64cf6..a3a72e0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,4 +24,4 @@ jobs: - name: Lint run: python -m mypy -p linehaul - name: Test - run: python -m pytest test_functions.py tests/unit + run: python -m pytest test_functions.py tests diff --git a/tests/test_strategies.py b/tests/test_strategies.py index 622249a..e7fd04d 100644 --- a/tests/test_strategies.py +++ b/tests/test_strategies.py @@ -12,7 +12,15 @@ import itertools -from hypothesis import assume, given, strategies as st, reproduce_failure, seed +from hypothesis import ( + assume, + given, + settings, + strategies as st, + reproduce_failure, + seed, + HealthCheck, +) from .strategies import version as st_version @@ -25,6 +33,7 @@ def _ver_2_list(version): reversed(list(itertools.dropwhile(lambda i: i == 0, reversed(version)))) ) + @settings(suppress_health_check=[HealthCheck.too_slow]) @given( st.data(), st.tuples( @@ -35,6 +44,7 @@ def test_greater_than_minimum(self, data, min_version): version = data.draw(st_version(min_version=min_version)) assert self._ver_2_list(version) >= self._ver_2_list(min_version) + @settings(suppress_health_check=[HealthCheck.too_slow]) @given( st.data(), st.tuples( @@ -47,6 +57,7 @@ def test_less_than_maximum(self, data, max_version): version = data.draw(st_version(max_version=max_version)) assert self._ver_2_list(version) <= self._ver_2_list(max_version) + @settings(suppress_health_check=[HealthCheck.too_slow]) @given( st.data(), st.tuples( @@ -73,16 +84,19 @@ def test_inbetween_min_and_max(self, data, versions): <= self._ver_2_list(max_version) ) + @settings(suppress_health_check=[HealthCheck.too_slow]) @given(st.data(), st.integers(min_value=1, max_value=100)) def test_produces_with_more_digits_than_min(self, data, min_digits): version = data.draw(st_version(min_digits=min_digits)) assert len(version.split(".")) >= min_digits + @settings(suppress_health_check=[HealthCheck.too_slow]) @given(st.data(), st.integers(min_value=2, max_value=100)) def test_produces_with_less_digits_than_max(self, data, max_digits): version = data.draw(st_version(max_digits=max_digits)) assert len(version.split(".")) <= max_digits + @settings(suppress_health_check=[HealthCheck.too_slow]) @given( st.data(), st.tuples( @@ -95,6 +109,7 @@ def test_produces_inbetween_min_and_max_digits(self, data, digits): version = data.draw(st_version(min_digits=min_digits, max_digits=max_digits)) assert min_digits <= len(version.split(".")) <= max_digits + @settings(suppress_health_check=[HealthCheck.too_slow]) @given( st.data(), st.tuples( From 3156c134a0884ddfd7dbcf5475de52ed832b3396 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 14 Jul 2026 14:31:20 +0000 Subject: [PATCH 2/2] Remove unused test strategy composites line_delimited_data and chunked are leftovers from the old streaming-reader linehaul; nothing imports them (only `version` is used, by test_strategies.py and the UA parser tests). Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01AQqEBHkvu6QDaidS4zYPVs --- tests/strategies.py | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/tests/strategies.py b/tests/strategies.py index abe6813..c3caed3 100644 --- a/tests/strategies.py +++ b/tests/strategies.py @@ -16,31 +16,6 @@ INF = float("inf") -@st.composite -def line_delimited_data(draw, max_line_size, min_lines=1): - n = draw(max_line_size) - data = st.binary(min_size=1, max_size=n).filter(lambda d: b"\n" not in d) - lines = draw( - st.lists(data, min_size=min_lines).filter( - lambda l: sum(map(len, l)) + len(l) <= n - ) - ) - return b"\n".join(lines) + b"\n" - - -@st.composite -def chunked(draw, source): - data = draw(source) - - chunk_sizes = [0] - chunk_sizes += draw( - st.lists(st.integers(0, len(data) - 1), unique=True).map(sorted) - ) - chunk_sizes += [len(data)] - - return [data[u:v] for u, v in zip(chunk_sizes, chunk_sizes[1:])] - - def _none_for_inf(v): if v is INF: return None