5

I have a number of unit tests that leverage a @composite strategy that I wrote. The strategy is quite slow (it generates complex objects) and from time to time one of the tests fails the too_slow health check. When that happens, I take a deep sigh and I add

@settings(suppress_health_check=(HealthCheck.too_slow,))

to the test.

Is there a way to suppress HealthCheck.too_slow once and for all, for all the tests that use the slow strategy?

Arek' Fu
  • 826
  • 8
  • 24
  • 1
    this looks like XY-problem: can you describe one of your `composite` strategies so we can find a way to rewrite it and make faster? – Azat Ibrakov Oct 03 '18 at 04:25

1 Answers1

3

You can change the global default settings using settings profiles, but there is no way to apply certain settings to a subset of your tests built-in to Hypothesis.

If you know you have a slow strategy I'd try to make that strategy faster - usually there are some serious optimisations available - and if I couldn't I'd just disable the particular health check. Just re-enable it occasionally to check for unexpectedly slow tests!

Zac Hatfield-Dodds
  • 2,455
  • 6
  • 19