|
| 1 | +[build-system] |
| 2 | +# require a recent setuptools for `license = ` support |
| 3 | +requires = ["setuptools >= 78.1.0", "wheel"] |
| 4 | +build-backend = "setuptools.build_meta" |
| 5 | + |
| 6 | +[project] |
| 7 | +name = "hypothesis" |
| 8 | +# see [tool.setuptools.dynamic] |
| 9 | +dynamic = ["version"] |
| 10 | +authors = [ |
| 11 | + { name = "David R. MacIver and Zac Hatfield-Dodds", email = "[email protected]" } |
| 12 | +] |
| 13 | +description = "A library for property-based testing" |
| 14 | +# Avoid changing this by hand. This is automatically updated by update_changelog_and_version |
| 15 | +readme = {"text" = """<div align="center"> |
| 16 | + <img src="https://raw.githubusercontent.com/HypothesisWorks/hypothesis/master/brand/dragonfly-rainbow.svg" width="300"> |
| 17 | +</div> |
| 18 | +
|
| 19 | +# Hypothesis |
| 20 | +
|
| 21 | +* [Website](https://hypothesis.works/) |
| 22 | +* [Documentation](https://hypothesis.readthedocs.io/en/latest/) |
| 23 | +* [Source code](https://github.com/hypothesisWorks/hypothesis/) |
| 24 | +* [Contributing](https://github.com/HypothesisWorks/hypothesis/blob/master/CONTRIBUTING.rst) |
| 25 | +* [Community](https://hypothesis.readthedocs.io/en/latest/community.html) |
| 26 | +
|
| 27 | +Hypothesis is the property-based testing library for Python. A property-based test asserts something for *all* inputs, and lets Hypothesis generate them — including inputs you may not have thought of. |
| 28 | +
|
| 29 | +```python |
| 30 | +from hypothesis import given, strategies as st |
| 31 | +
|
| 32 | +
|
| 33 | +@given(st.lists(st.integers() | st.floats())) |
| 34 | +def test_matches_builtin(ls): |
| 35 | + assert sorted(ls) == my_sort(ls) |
| 36 | +``` |
| 37 | +
|
| 38 | +Additionally, when a property fails, Hypothesis doesn't just report any failing example — it reports the simplest possible one. This makes property-based tests a powerful tool for debugging, as well as testing. |
| 39 | +
|
| 40 | +For instance, |
| 41 | +
|
| 42 | +```python |
| 43 | +def my_sort(ls): |
| 44 | + return list(reversed(sorted(ls, reverse=True))) |
| 45 | +``` |
| 46 | +
|
| 47 | +fails with: |
| 48 | +
|
| 49 | +``` |
| 50 | +Falsifying example: test_matches_builtin(ls=[0, math.nan]) |
| 51 | +``` |
| 52 | +
|
| 53 | +### Installation |
| 54 | +
|
| 55 | +To install Hypothesis: |
| 56 | +
|
| 57 | +``` |
| 58 | +pip install hypothesis |
| 59 | +``` |
| 60 | +
|
| 61 | +There are also [optional extras available](https://hypothesis.readthedocs.io/en/latest/extras.html). |
| 62 | +""", "content-type" = "text/markdown"} |
| 63 | +license = "MPL-2.0" |
| 64 | +requires-python = ">= 3.9" |
| 65 | +keywords = ["python", "testing", "fuzzing", "property-based-testing"] |
| 66 | +classifiers = [ |
| 67 | + "Development Status :: 5 - Production/Stable", |
| 68 | + "Framework :: Hypothesis", |
| 69 | + "Framework :: Pytest", |
| 70 | + "Intended Audience :: Developers", |
| 71 | + "Operating System :: Unix", |
| 72 | + "Operating System :: POSIX", |
| 73 | + "Operating System :: Microsoft :: Windows", |
| 74 | + "Programming Language :: Python", |
| 75 | + "Programming Language :: Python :: 3", |
| 76 | + "Programming Language :: Python :: 3 :: Only", |
| 77 | + "Programming Language :: Python :: 3.9", |
| 78 | + "Programming Language :: Python :: 3.10", |
| 79 | + "Programming Language :: Python :: 3.11", |
| 80 | + "Programming Language :: Python :: 3.12", |
| 81 | + "Programming Language :: Python :: 3.13", |
| 82 | + "Programming Language :: Python :: Implementation :: CPython", |
| 83 | + "Programming Language :: Python :: Implementation :: PyPy", |
| 84 | + "Topic :: Education :: Testing", |
| 85 | + "Topic :: Software Development :: Testing", |
| 86 | + "Typing :: Typed", |
| 87 | +] |
| 88 | + |
| 89 | +dependencies = [ |
| 90 | + "attrs>=22.2.0", |
| 91 | + "exceptiongroup>=1.0.0; python_version<'3.11'", |
| 92 | + "sortedcontainers>=2.1.0,<3.0.0", |
| 93 | +] |
| 94 | + |
| 95 | +[project.urls] |
| 96 | +homepage = "https://hypothesis.works" |
| 97 | +source = "https://github.com/HypothesisWorks/hypothesis" |
| 98 | +changelog = "https://hypothesis.readthedocs.io/en/latest/changes.html" |
| 99 | +documentation = "https://hypothesis.readthedocs.io" |
| 100 | +issues = "https://github.com/HypothesisWorks/hypothesis/issues" |
| 101 | + |
| 102 | +[project.optional-dependencies] |
| 103 | +cli = ["click>=7.0", "black>=19.10b0", "rich>=9.0.0"] |
| 104 | +codemods = ["libcst>=0.3.16"] |
| 105 | +ghostwriter = ["black>=19.10b0"] |
| 106 | +pytz = ["pytz>=2014.1"] |
| 107 | +dateutil = ["python-dateutil>=1.4"] |
| 108 | +lark = ["lark>=0.10.1"] # probably still works with old `lark-parser` too |
| 109 | +numpy = ["numpy>=1.19.3"] # oldest with wheels for non-EOL Python (for now) |
| 110 | +pandas = ["pandas>=1.1"] |
| 111 | +pytest = ["pytest>=4.6"] |
| 112 | +dpcontracts = ["dpcontracts>=0.4"] |
| 113 | +redis = ["redis>=3.0.0"] |
| 114 | +crosshair = ["hypothesis-crosshair>=0.0.20", "crosshair-tool>=0.0.84"] |
| 115 | +# zoneinfo is an odd one: every dependency is platform-conditional. |
| 116 | +zoneinfo = ["tzdata>=2025.1; sys_platform == 'win32' or sys_platform == 'emscripten'"] |
| 117 | +# We only support Django versions with upstream support - see |
| 118 | +# https://www.djangoproject.com/download/#supported-versions |
| 119 | +# We also leave the choice of timezone library to the user, since it |
| 120 | +# might be zoneinfo or pytz depending on version and configuration. |
| 121 | +django = ["django>=4.2"] |
| 122 | +watchdog = ["watchdog>=4.0.0"] |
| 123 | +# Avoid changing this by hand. This is automatically updated by update_changelog_and_version |
| 124 | +all = ["black>=19.10b0", "click>=7.0", "crosshair-tool>=0.0.84", "django>=4.2", "dpcontracts>=0.4", "hypothesis-crosshair>=0.0.20", "lark>=0.10.1", "libcst>=0.3.16", "numpy>=1.19.3", "pandas>=1.1", "pytest>=4.6", "python-dateutil>=1.4", "pytz>=2014.1", "redis>=3.0.0", "rich>=9.0.0", "tzdata>=2025.1; sys_platform == 'win32' or sys_platform == 'emscripten'", "watchdog>=4.0.0"] |
| 125 | + |
| 126 | +[tool.setuptools.dynamic] |
| 127 | +version = {attr = "hypothesis.version.__version__"} |
| 128 | + |
| 129 | +[tool.setuptools.package-data] |
| 130 | +hypothesis = ["vendor/tlds-alpha-by-domain.txt"] |
| 131 | + |
| 132 | +[project.scripts] |
| 133 | +hypothesis = "hypothesis.extra.cli:main" |
| 134 | + |
| 135 | +[project.entry-points.pytest11] |
| 136 | +hypothesispytest = "_hypothesis_pytestplugin" |
0 commit comments