コード例 #1
0
 def fail_health_check(message):
     message += (
         '\nSee http://hypothesis.readthedocs.org/en/latest/health'
         'checks.html for more information about this.')
     if settings.strict:
         raise FailedHealthCheck(message)
     else:
         warnings.warn(FailedHealthCheck(message))
コード例 #2
0
ファイル: core.py プロジェクト: sritchie/hypothesis-python
def fail_health_check(settings, message, label):
    if label in settings.suppress_health_check:
        return
    message += ('\nSee https://hypothesis.readthedocs.io/en/latest/health'
                'checks.html for more information about this. ')
    message += ('If you want to disable just this health check, add %s '
                'to the suppress_health_check settings for this test.') % (
                    label, )
    raise FailedHealthCheck(message)
コード例 #3
0
ファイル: core.py プロジェクト: Teraisa/udacity_databases
def fail_health_check(settings, message, label):
    # Tell pytest to omit the body of this function from tracebacks
    # http://doc.pytest.org/en/latest/example/simple.html#writing-well-integrated-assertion-helpers
    __tracebackhide__ = True
    if label in settings.suppress_health_check:
        return
    message += ('\nSee https://hypothesis.readthedocs.io/en/latest/health'
                'checks.html for more information about this. ')
    message += ('If you want to disable just this health check, add %s '
                'to the suppress_health_check settings for this test.') % (
                    label, )
    raise FailedHealthCheck(message)
コード例 #4
0
ファイル: core.py プロジェクト: llnz/hypothesis
 def evaluate_test_data(data):
     if perform_health_check and not performed_random_check[0]:
         initial_state = getglobalrandomstate()
         performed_random_check[0] = True
     else:
         initial_state = None
     try:
         result = test_runner(data, reify_and_execute(
             search_strategy, test,
         ))
         if result is not None and settings.perform_health_check:
             raise FailedHealthCheck((
                 'Tests run under @given should return None, but '
                 '%s returned %r instead.'
             ) % (test.__name__, result), settings)
         return False
     except UnsatisfiedAssumption:
         data.mark_invalid()
     except (
         HypothesisDeprecationWarning, FailedHealthCheck,
         StopTest,
     ):
         raise
     except Exception:
         last_exception[0] = traceback.format_exc()
         verbose_report(last_exception[0])
         data.mark_interesting()
     finally:
         if (
             initial_state is not None and
             getglobalrandomstate() != initial_state
         ):
             fail_health_check(
                 'Your test used the global random module. '
                 'This is unlikely to work correctly. You should '
                 'consider using the randoms() strategy from '
                 'hypothesis.strategies instead. Alternatively, '
                 'you can use the random_module() strategy to '
                 'explicitly seed the random module.')
コード例 #5
0
 def is_template_example(xs):
     if perform_health_check and not warned_random[0]:
         initial_state = getglobalrandomstate()
     record_repr = [None]
     try:
         result = test_runner(
             reify_and_execute(
                 search_strategy,
                 xs,
                 test,
                 record_repr=record_repr,
             ))
         if result is not None and settings.perform_health_check:
             raise FailedHealthCheck(
                 ('Tests run under @given should return None, but '
                  '%s returned %r instead.') %
                 (test.__name__, result), settings)
         return False
     except (HypothesisDeprecationWarning, FailedHealthCheck,
             UnsatisfiedAssumption):
         raise
     except Exception:
         last_exception[0] = traceback.format_exc()
         repr_for_last_exception[0] = record_repr[0]
         verbose_report(last_exception[0])
         return True
     finally:
         if (not warned_random[0] and perform_health_check
                 and getglobalrandomstate() != initial_state):
             warned_random[0] = True
             fail_health_check(
                 'Your test used the global random module. '
                 'This is unlikely to work correctly. You should '
                 'consider using the randoms() strategy from '
                 'hypothesis.strategies instead. Alternatively, '
                 'you can use the random_module() strategy to '
                 'explicitly seed the random module.')
コード例 #6
0
ファイル: core.py プロジェクト: llnz/hypothesis
 def fail_health_check(message):
     message += (
         '\nSee http://hypothesis.readthedocs.org/en/latest/health'
         'checks.html for more information about this.'
     )
     raise FailedHealthCheck(message)