nw-pbt-python

Solid

Python property-based testing with Hypothesis framework, strategies, and pytest integration

Testing & QA 542 stars 57 forks Updated yesterday NOASSERTION

Install

View on GitHub

Quality Score: 87/100

Stars 20%
91
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# PBT Python -- Hypothesis ## Framework Selection **Hypothesis** is the only serious choice for Python PBT. No competitive alternatives. - 10+ years mature, very actively maintained - Used by PyTorch, NumPy, pandas - Seamless pytest integration (no plugin needed) ## Quick Start ```python from hypothesis import given, assume, settings, HealthCheck from hypothesis import strategies as st @given(st.lists(st.integers())) def test_sort_idempotent(xs): assert sorted(sorted(xs)) == sorted(xs) # Run: pytest test_file.py ``` ## Generator (Strategy) Cheat Sheet ### Primitives ```python st.integers() # any int st.integers(min_value=0, max_value=99) # bounded st.floats() # includes NaN, inf st.floats(allow_nan=False, allow_infinity=False) st.text() # unicode strings st.text(min_size=1, max_size=50) st.binary() # bytes st.booleans() st.none() ``` ### Collections ```python st.lists(st.integers()) st.lists(st.integers(), min_size=1, max_size=10) st.sets(st.integers()) st.frozensets(st.text()) st.dictionaries(st.text(), st.integers()) st.tuples(st.integers(), st.text()) ``` ### Combinators ```python st.one_of(st.integers(), st.text()) # union st.sampled_from([1, 2, 3]) # pick from list st.just(42) # constant # Map (transform) st.integers().map(lambda x: x * 2) # even integers # Filter (use sparingly) st.integers().filter(lambda x: ...

Details

Author
nWave-ai
Repository
nWave-ai/nWave
Created
3 months ago
Last Updated
yesterday
Language
Python
License
NOASSERTION

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category