FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: add fuzzing coverage for incoming packet parsing (#1829) · python-zeroconf/python-zeroconf@868391c · GitHub

Commit 868391c

Browse files
authored
test: add fuzzing coverage for incoming packet parsing (#1829)
1 parent 9e732c5 commit 868391c

5 files changed

Lines changed: 298 additions & 1 deletion

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ docs/_build/
1818
/dist/
1919
/zeroconf.egg-info/
2020
/src/**/*.c
21+
.hypothesis/

‎poetry.lock‎

Lines changed: 128 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ setuptools = ">=83.0.0,<84.0.0"
9292
pytest-timeout = "^2.1.0"
9393
pytest-codspeed = ">=5.0.3,<6.0"
9494
blockbuster = ">=1.5.27,<2.0.0"
95+
hypothesis = {version = "^6.165.10", markers = "implementation_name == 'cpython'"}
9596

9697
[tool.poetry.group.docs.dependencies]
9798
sphinx = "^7.4.7 || ^8.1.3"

‎tests/conftest.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from __future__ import annotations
44

5+
import importlib.util
6+
import os
57
import threading
68
from collections.abc import AsyncGenerator, Generator, Iterator
79
from unittest.mock import patch
@@ -15,6 +17,20 @@
1517
from zeroconf._services import info as service_info
1618
from zeroconf.asyncio import AsyncZeroconf
1719

20+
# The dev dependency group only installs hypothesis on CPython (the CI
21+
# matrix pins pypy-3.10 and hypothesis ships no pp310 wheels), and a
22+
# non-dev install has no hypothesis at all.
23+
collect_ignore: list[str] = []
24+
if importlib.util.find_spec("hypothesis") is None:
25+
collect_ignore.append("test_fuzz_incoming.py")
26+
else:
27+
from hypothesis import settings as _hypothesis_settings
28+
29+
# Deterministic in CI; set HYPOTHESIS_PROFILE=long for a deep local run.
30+
_hypothesis_settings.register_profile("ci", derandomize=True, max_examples=200, deadline=None)
31+
_hypothesis_settings.register_profile("long", max_examples=50000, deadline=None)
32+
_hypothesis_settings.load_profile(os.environ.get("HYPOTHESIS_PROFILE", "ci"))
33+
1834
try:
1935
from blockbuster import BlockBuster, blockbuster_ctx
2036
except ImportError: # platforms without blockbuster (e.g. PyPy under QEMU)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL