Debian Codegraph @

hypothesis-python/docs/how-to/suppress-healthchecks.rst

raw
1 Suppress a health check everywhere
2 ==================================
3
4 Hypothesis sometimes raises a |HealthCheck| to indicate that your test may be less effective than you expect, slower than you expect, unlikely to generate effective examples, or otherwise has silently degraded performance.
5
6 While |HealthCheck| can be useful to proactively identify issues, you may not care about certain classes of them. If you want to disable a |HealthCheck| everywhere, you can register and load a settings profile with |settings.register_profile| and |settings.load_profile|. Place the following code in any file which is loaded before running your tests (or in ``conftest.py``, if using pytest):
7
8 .. code-block:: python
9
10 from hypothesis import HealthCheck, settings
11
12 settings.register_profile(
13 "my_profile", suppress_health_check=[HealthCheck.filter_too_much]
14 )
15 settings.load_profile("my_profile")
16
17 This profile in particular suppresses the |HealthCheck.filter_too_much| health check for all tests. The exception is if a test has a |@settings| which explicitly sets a different value for ``suppress_health_check``, in which case the profile value will be overridden by the local settings value.
18
19 I want to suppress all health checks!
20 -------------------------------------
21
22 .. warning::
23
24 We strongly recommend that you suppress health checks as you encounter them, rather than using a blanket suppression. Several health checks check for subtle interactions that may save you hours of debugging, such as |HealthCheck.function_scoped_fixture| and |HealthCheck.differing_executors|.
25
26 If you really want to suppress *all* health checks, for instance to speed up interactive prototyping, you can:
27
28 .. code-block:: python
29
30 from hypothesis import HealthCheck, settings
31
32 settings.register_profile("my_profile", suppress_health_check=list(HealthCheck))
33 settings.load_profile("my_profile")