healthcheck.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # coding=utf-8
  2. #
  3. # This file is part of Hypothesis, which may be found at
  4. # https://github.com/HypothesisWorks/hypothesis-python
  5. #
  6. # Most of this work is copyright (C) 2013-2018 David R. MacIver
  7. # (david@drmaciver.com), but it contains contributions by others. See
  8. # CONTRIBUTING.rst for a full list of people who may hold copyright, and
  9. # consult the git log if you need to determine who owns an individual
  10. # contribution.
  11. #
  12. # This Source Code Form is subject to the terms of the Mozilla Public License,
  13. # v. 2.0. If a copy of the MPL was not distributed with this file, You can
  14. # obtain one at http://mozilla.org/MPL/2.0/.
  15. #
  16. # END HEADER
  17. from __future__ import division, print_function, absolute_import
  18. from hypothesis.errors import FailedHealthCheck
  19. def fail_health_check(settings, message, label):
  20. # Tell pytest to omit the body of this function from tracebacks
  21. # http://doc.pytest.org/en/latest/example/simple.html#writing-well-integrated-assertion-helpers
  22. __tracebackhide__ = True
  23. if label in settings.suppress_health_check:
  24. return
  25. if not settings.perform_health_check:
  26. return
  27. message += (
  28. '\nSee https://hypothesis.readthedocs.io/en/latest/health'
  29. 'checks.html for more information about this. '
  30. 'If you want to disable just this health check, add %s '
  31. 'to the suppress_health_check settings for this test.'
  32. ) % (label,)
  33. raise FailedHealthCheck(message, label)