summarylogtreecommitdiffstats
path: root/0001-Silence-health-check-errors-form-hypothesis.patch
blob: 29fedf2d6fc569971a97715011568d42e4acf6e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From c8f539dfeaf6b3e27ba5cac5e09ea69137a84041 Mon Sep 17 00:00:00 2001
From: LingMan <LingMan@users.noreply.github.com>
Date: Mon, 31 Jul 2023 19:36:24 +0200
Subject: [PATCH] Silence health check errors form hypothesis

Depending on the random input data generated by hypothesis for the `test_hostnames_ascii_nolead`
test, it may complain about too much data being filtered out or the test running too slow:

```
E       FailedHealthCheck: It looks like your strategy is filtering out a lot of data. Health check
        found 50 filtered examples but only 3 good ones. This will make your tests much slower, and
        also will probably distort the data generation quite a lot. You should adapt your strategy
        to filter less. This can also be caused by a low max_leaves parameter in recursive() calls
E       See https://hypothesis.readthedocs.io/en/latest/healthchecks.html for more information
        about this. If you want to disable just this health check, add HealthCheck.filter_too_much
        to the suppress_health_check settings for this test.
```

These fail the test even though they are ultimately harmless. Silence them so the package builds
consistently.
---
 src/hyperlink/test/test_hypothesis.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/hyperlink/test/test_hypothesis.py b/src/hyperlink/test/test_hypothesis.py
index 776ed7b..2b86700 100644
--- a/src/hyperlink/test/test_hypothesis.py
+++ b/src/hyperlink/test/test_hypothesis.py
@@ -18,7 +18,7 @@ else:
     except ImportError:
         from mock import patch  # type: ignore[misc]
 
-    from hypothesis import given, settings
+    from hypothesis import given, settings, HealthCheck
     from hypothesis.strategies import SearchStrategy, data
 
     from idna import IDNAError, check_label, encode as idna_encode
@@ -173,6 +173,7 @@ else:
                     "Invalid ASCII host name: {!r}".format(hostname)
                 )
 
+        @settings(suppress_health_check=[HealthCheck.filter_too_much, HealthCheck.too_slow])
         @given(hostnames(allow_leading_digit=False, allow_idn=False))
         def test_hostnames_ascii_nolead(self, hostname):
             # type: (Text) -> None
-- 
2.41.0