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 typing import TYPE_CHECKING
12
13from hypothesis.errors import FailedHealthCheck
14
15if TYPE_CHECKING:
16 from hypothesis._settings import HealthCheck, settings as Settings
17
18
19def fail_health_check(
20 settings: "Settings", message: str, health_check: "HealthCheck"
21) -> None:
22 # Tell pytest to omit the body of this function from tracebacks
23 # https://docs.pytest.org/en/latest/example/simple.html#writing-well-integrated-assertion-helpers
24 __tracebackhide__ = True
25
26 if health_check in settings.suppress_health_check:
27 return
28 raise FailedHealthCheck(message)