|
15 | 15 | from typing import Any, cast |
16 | 16 |
|
17 | 17 | import pytest |
18 | | -from hypothesis import HealthCheck, assume, example, given, settings |
| 18 | +from hypothesis import ( |
| 19 | + HealthCheck, |
| 20 | + example, |
| 21 | + given, |
| 22 | + settings, |
| 23 | +) |
19 | 24 | from lxml.etree import ( |
20 | 25 | QName, |
21 | 26 | _Attrib as _Attrib, |
@@ -109,12 +114,15 @@ def test_namespaces_arg_ok(self, svg_root: _Element) -> None: |
109 | 114 |
|
110 | 115 | # range objects can cause indefinite hang |
111 | 116 | @settings(suppress_health_check=[HealthCheck.too_slow], max_examples=300) |
112 | | - @given(thing=_st.all_instances_except_of_type(Mapping, NoneType, range)) |
| 117 | + @given( |
| 118 | + thing=_st.all_instances_except_of_type(Mapping, NoneType, range).filter( |
| 119 | + lambda x: x is not NotImplemented and bool(x) |
| 120 | + ) |
| 121 | + ) |
113 | 122 | @pytest.mark.slow |
114 | 123 | def test_namespaces_arg_bad_1( |
115 | 124 | self, disposable_element: _Element, thing: Any |
116 | 125 | ) -> None: |
117 | | - assume(thing is not NotImplemented and bool(thing)) |
118 | 126 | # pyrefly: ignore[no-matching-overload] |
119 | 127 | with pytest.raises((TypeError, AttributeError)): # too diversified |
120 | 128 | _ = disposable_element.iterfind("foo", namespaces=thing) |
@@ -175,12 +183,15 @@ def test_namespaces_arg_ok(self, svg_root: _Element) -> None: |
175 | 183 |
|
176 | 184 | # range objects can cause indefinite hang |
177 | 185 | @settings(suppress_health_check=[HealthCheck.too_slow], max_examples=300) |
178 | | - @given(thing=_st.all_instances_except_of_type(Mapping, NoneType, range)) |
| 186 | + @given( |
| 187 | + thing=_st.all_instances_except_of_type(Mapping, NoneType, range).filter( |
| 188 | + lambda x: x is not NotImplemented and bool(x) |
| 189 | + ) |
| 190 | + ) |
179 | 191 | @pytest.mark.slow |
180 | 192 | def test_namespaces_arg_bad_1( |
181 | 193 | self, disposable_element: _Element, thing: Any |
182 | 194 | ) -> None: |
183 | | - assume(thing is not NotImplemented and bool(thing)) |
184 | 195 | # pyrefly: ignore[no-matching-overload] |
185 | 196 | with pytest.raises((TypeError, AttributeError)): # too diversified |
186 | 197 | _ = disposable_element.find("foo", namespaces=thing) |
@@ -241,12 +252,15 @@ def test_namespaces_arg_ok(self, svg_root: _Element) -> None: |
241 | 252 |
|
242 | 253 | # range objects can cause indefinite hang |
243 | 254 | @settings(suppress_health_check=[HealthCheck.too_slow], max_examples=300) |
244 | | - @given(thing=_st.all_instances_except_of_type(Mapping, NoneType, range)) |
| 255 | + @given( |
| 256 | + thing=_st.all_instances_except_of_type(Mapping, NoneType, range).filter( |
| 257 | + lambda x: x is not NotImplemented and bool(x) |
| 258 | + ) |
| 259 | + ) |
245 | 260 | @pytest.mark.slow |
246 | 261 | def test_namespaces_arg_bad_1( |
247 | 262 | self, disposable_element: _Element, thing: Any |
248 | 263 | ) -> None: |
249 | | - assume(thing is not NotImplemented and bool(thing)) |
250 | 264 | # pyrefly: ignore[no-matching-overload] |
251 | 265 | with pytest.raises((TypeError, AttributeError)): # too diversified |
252 | 266 | _ = disposable_element.findall("foo", namespaces=thing) |
@@ -329,12 +343,15 @@ def test_namespaces_arg_ok(self, svg_root: _Element) -> None: |
329 | 343 |
|
330 | 344 | # range objects can cause indefinite hang |
331 | 345 | @settings(suppress_health_check=[HealthCheck.too_slow], max_examples=300) |
332 | | - @given(thing=_st.all_instances_except_of_type(Mapping, NoneType, range)) |
| 346 | + @given( |
| 347 | + thing=_st.all_instances_except_of_type(Mapping, NoneType, range).filter( |
| 348 | + lambda x: x is not NotImplemented and bool(x) |
| 349 | + ) |
| 350 | + ) |
333 | 351 | @pytest.mark.slow |
334 | 352 | def test_namespaces_arg_bad_1( |
335 | 353 | self, disposable_element: _Element, thing: Any |
336 | 354 | ) -> None: |
337 | | - assume(thing is not NotImplemented and bool(thing)) |
338 | 355 | # pyrefly: ignore[no-matching-overload] |
339 | 356 | with pytest.raises((TypeError, AttributeError)): # too diversified |
340 | 357 | _ = disposable_element.findtext("foo", namespaces=thing) |
|
0 commit comments