1# This file is part of Hypothesis, which may be found at
2# https://github.com/HypothesisWorks/hypothesis/
3#
4# Copyright the Hypothesis Authors.
5# Individual contributors are listed in AUTHORS.rst and the git log.
6#
7# This Source Code Form is subject to the terms of the Mozilla Public License,
8# v. 2.0. If a copy of the MPL was not distributed with this file, You can
9# obtain one at https://mozilla.org/MPL/2.0/.
10
11from hypothesis.errors import FailedHealthCheck
12
13
14def fail_health_check(settings, message, label):
15 # Tell pytest to omit the body of this function from tracebacks
16 # https://docs.pytest.org/en/latest/example/simple.html#writing-well-integrated-assertion-helpers
17 __tracebackhide__ = True
18
19 if label in settings.suppress_health_check:
20 return
21 message += (
22 "\nSee "
23 "https://hypothesis.readthedocs.io/en/latest/reference/api.html#hypothesis.HealthCheck "
24 "for more information about this. "
25 f"If you want to disable just this health check, add {label} "
26 "to the suppress_health_check settings for this test."
27 )
28 raise FailedHealthCheck(message)