Accomodate known slow tests in hypothesis deadline
Marco Ricci

Marco Ricci commited on 2024-10-01 11:36:02
Zeige 1 geänderte Dateien mit 10 Einfügungen und 0 Löschungen.


With coverage measurement enabled, program execution can slow down by
a factor of roughly 40 if the Python tracer is used, instead of the
C tracer.  In some configurations, only the Python tracer is available.
To avoid timing out on tests that otherwise would be okay with default
settings, manually reset those tests' deadline to 40 times their
original value; currently only one test is affected.
... ...
@@ -394,6 +394,16 @@ class TestHypotheses:
394 394
                     len(set(snippet)) > 1
395 395
                 ), 'Password does not satisfy character repeat constraints.'
396 396
 
397
+    # This test tends to time out when using coverage without the
398
+    # C tracer, which in my testing leads to a roughly 40-fold execution
399
+    # time. So reset the deadline accordingly.
400
+    @hypothesis.settings(
401
+        deadline=(
402
+            40 * deadline  # type: ignore[name-defined]
403
+            if (deadline := hypothesis.settings().deadline) is not None
404
+            else None
405
+        )
406
+    )
397 407
     @hypothesis.given(
398 408
         phrase=strategies.one_of(
399 409
             strategies.binary(min_size=1),
400 410