You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hypothesis-python/docs/changelog.rst
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,48 @@ Hypothesis 6.x
18
18
19
19
.. include:: ../RELEASE.rst
20
20
21
+
.. _v6.137.1:
22
+
23
+
--------------------
24
+
6.137.1 - 2025-08-05
25
+
--------------------
26
+
27
+
Fixes a bug with solver-based :ref:`alternative backends <alternative-backends>` (like `crosshair <https://github.com/pschanely/CrossHair>`_) where symbolic values passed to |event| would not be realized to concrete values at the end of the test case.
28
+
29
+
.. _v6.137.0:
30
+
31
+
--------------------
32
+
6.137.0 - 2025-08-05
33
+
--------------------
34
+
35
+
Add the |add_observability_callback|, |remove_observability_callback|, |with_observability_callback|, and |observability_enabled| methods to the :ref:`observability <observability>` interface. The previous |TESTCASE_CALLBACKS| is deprecated.
36
+
37
+
This release also adds better threading support to observability callbacks. An observability callback will now only be called for observations generated by the same thread.
38
+
39
+
.. _v6.136.9:
40
+
41
+
--------------------
42
+
6.136.9 - 2025-08-04
43
+
--------------------
44
+
45
+
Fix a threading race condition in |st.one_of| initialization.
46
+
47
+
.. _v6.136.8:
48
+
49
+
--------------------
50
+
6.136.8 - 2025-08-04
51
+
--------------------
52
+
53
+
Improve the error messages and documentation for |HealthCheck|. Among others, the messaging is now more clear that health checks are proactive warnings, not correctness errors.
54
+
55
+
.. _v6.136.7:
56
+
57
+
--------------------
58
+
6.136.7 - 2025-08-01
59
+
--------------------
60
+
61
+
Improve detection of sys.monitoring to avoid errors on GraalPy.
@@ -55,7 +51,6 @@ patch release of any version of Python it supports. Earlier releases should work
55
51
and bugs in them will get fixed if reported, but they're not tested in CI and
56
52
no guarantees are made.
57
53
58
-
-----------------
59
54
Operating systems
60
55
-----------------
61
56
@@ -69,7 +64,6 @@ operating system it probably won't stay fixed due to the inevitable march of tim
69
64
70
65
.. _framework-compatibility:
71
66
72
-
------------------
73
67
Testing frameworks
74
68
------------------
75
69
@@ -106,7 +100,6 @@ In terms of what's actually *known* to work:
106
100
* :pypi:`coverage` works out of the box with Hypothesis; our own test suite has
107
101
100% branch coverage.
108
102
109
-
-----------------
110
103
Optional packages
111
104
-----------------
112
105
@@ -117,23 +110,33 @@ all versions that are supported upstream.
117
110
118
111
.. _thread-safety-policy:
119
112
120
-
--------------------
121
113
Thread-Safety Policy
122
114
--------------------
123
115
124
-
As discussed in :issue:`2719`, Hypothesis is not truly thread-safe and that's unlikely to change in the future. This policy therefore describes what you *can* expect if you use Hypothesis with multiple threads.
116
+
As of :version:`6.136.9`, Hypothesis is thread-safe. Each of the following is fully supported, and tested regularly in CI:
125
117
126
-
**Running tests in multiple processes**, e.g. with ``pytest -n auto``, is fully supported and we test this regularly in CI - thanks to process isolation, we only need to ensure that :class:`~hypothesis.database.DirectoryBasedExampleDatabase` can't tread on its own toes too badly. If you find a bug here we will fix it ASAP.
118
+
* Running tests in multiple processes
119
+
* Running separate tests in multiple threads
120
+
* Running the same test in multiple threads
127
121
128
-
**Running separate tests in multiple threads** is not something we design or test for, and is not formally supported. That said, anecdotally it does mostly work and we would like it to keep working - we accept reasonable patches and low-priority bug reports. The main risks here are global state, shared caches, and cached strategies.
122
+
If you find a bug here, please report it. The main risks internally are global state, shared caches, and cached strategies.
129
123
130
-
**Running the same test in multiple threads**, or using multiple threads within the same test, makes it pretty easy to trigger internal errors. We usually accept patches for such issues unless readability or single-thread performance suffer.
124
+
Thread usage inside tests
125
+
~~~~~~~~~~~~~~~~~~~~~~~~~
131
126
132
-
Hypothesis assumes that tests are single-threaded, or do a sufficiently-good job of pretending to be single-threaded. Tests that use helper threads internally should be OK, but the user must be careful to ensure that test outcomes are still deterministic. In particular it counts as nondeterministic if helper-thread timing changes the sequence of dynamic draws using e.g. the |st.data| strategy.
127
+
.. TODO_DOCS: link to not-yet-merged flaky failure tutorial page
133
128
134
-
Interacting with any Hypothesis APIs from helper threads might do weird/bad things, so avoid that too - we rely on thread-local variables in a few places, and haven't explicitly tested/audited how they respond to cross-thread API calls. While |st.data| and equivalents are the most obvious danger, other APIs might also be subtly affected.
129
+
Tests that spawn threads internally are supported by Hypothesis.
130
+
131
+
However, these as with any Hypothesis test, these tests must have deterministic test outcomes and data generation. For example, if timing changes in the threads change the sequence of dynamic draws from |st.composite| or |st.data|, Hypothesis may report the test as flaky. The solution here is to refactor data generation so it does not depend on test timings.
132
+
133
+
Cross-thread API calls
134
+
~~~~~~~~~~~~~~~~~~~~~~
135
+
136
+
In theory, Hypothesis supports cross-thread API calls, for instance spawning a thread inside of a test and using that to draw from |st.composite| or |st.data|, or to call |event|, |target|, or |assume|.
137
+
138
+
However, we have not explicitly audited this behavior, and do not regularly test it in our CI. If you find a bug here, please report it. If our investigation determines that we cannot support cross-thread calls for the feature in question, we will update this page accordingly.
Copy file name to clipboardExpand all lines: hypothesis-python/docs/reference/api.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -478,7 +478,7 @@ Note that the interpretation of both input and output bytestrings is specific to
478
478
Interaction with settings
479
479
~~~~~~~~~~~~~~~~~~~~~~~~~
480
480
481
-
``fuzz_one_input`` uses just enough of Hypothesis' internals to drive your test function with a fuzzer-provided bytestring, and most settings therefore have no effect in this mode. We recommend running your tests the usual way before fuzzing to get the benefits of healthchecks, as well as afterwards to replay, shrink, deduplicate, and report whatever errors were discovered.
481
+
``fuzz_one_input`` uses just enough of Hypothesis' internals to drive your test function with a fuzzer-provided bytestring, and most settings therefore have no effect in this mode. We recommend running your tests the usual way before fuzzing to get the benefits of health checks, as well as afterwards to replay, shrink, deduplicate, and report whatever errors were discovered.
482
482
483
483
- The :obj:`~hypothesis.settings.database` setting *is* used by fuzzing mode - adding failures to the database to be replayed when you next run your tests is our preferred reporting mechanism and response to `the 'fuzzer taming' problem <https://blog.regehr.org/archives/925>`__.
484
484
- The :obj:`~hypothesis.settings.verbosity` and :obj:`~hypothesis.settings.stateful_step_count` settings work as usual.
0 commit comments