Skip to content

Commit

Permalink
perf(test): Disable HealthCheck for all negative type tests
Browse files Browse the repository at this point in the history
All of them can potentially warn even for non-CI environments, when virtual envs are created fresh and not cached
  • Loading branch information
abelcheung committed Dec 12, 2024
1 parent 6c5b231 commit 683d933
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
20 changes: 12 additions & 8 deletions tests/runtime/html/test_link_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
)

import pytest
from hypothesis import given, settings
from hypothesis import (
HealthCheck,
given,
settings,
)
from lxml.etree import (
LXML_VERSION,
XPathResultError,
Expand Down Expand Up @@ -190,7 +194,7 @@ def test_wrong_type_no_raise(self, bightml_root: HtmlElement) -> None:
links = find_rel_links(bightml_root, cast(Any, bytearray(b)))
assert len(links) == 0

@settings(max_examples=500)
@settings(suppress_health_check=[HealthCheck.too_slow], max_examples=500)
@given(t=_st.all_instances_except_of_type(str, bytes, bytearray))
@pytest.mark.slow
def test_wrong_type_raises(
Expand Down Expand Up @@ -224,7 +228,7 @@ def _non_xpathobject_filter(x: Any) -> bool:
return len(x) > 0
return (x.stop - x.start) / x.step > 0

@settings(max_examples=500)
@settings(suppress_health_check=[HealthCheck.too_slow], max_examples=500)
@given(
t=_st.all_instances_except_of_type(
str,
Expand Down Expand Up @@ -290,7 +294,7 @@ def test_handle_failures_valid_type(
else:
assert old != new

@settings(max_examples=500)
@settings(suppress_health_check=[HealthCheck.too_slow], max_examples=500)
@given(
t=_st.all_instances_except_of_type().filter(
lambda x: x not in ("discard", "ignore", None)
Expand Down Expand Up @@ -330,7 +334,7 @@ def test_handle_failures_valid_type(
else:
assert old != new

@settings(max_examples=500)
@settings(suppress_health_check=[HealthCheck.too_slow], max_examples=500)
@given(
t=_st.all_instances_except_of_type().filter(
lambda _: _ not in ("ignore", "discard", None)
Expand All @@ -348,7 +352,7 @@ def test_handle_failures_wrong_type(
# Not testing resolve_base_href type, as it is a truthy/falsy argument
# that can be anything

@settings(max_examples=500)
@settings(suppress_health_check=[HealthCheck.too_slow], max_examples=500)
@given(t=_st.all_instances_except_of_type(str, NoneType).filter(bool))
@pytest.mark.slow
def test_base_href(
Expand All @@ -371,7 +375,7 @@ def test_link_repl_func_is_callable(

# QName has the unintended consequence of doing tag name check while
# replaced link is an attribute value, thus raising ValueError instead
@settings(max_examples=500)
@settings(suppress_health_check=[HealthCheck.too_slow], max_examples=500)
@given(
t=_st.all_instances_except_of_type(
*attr_value_types.allow,
Expand Down Expand Up @@ -405,7 +409,7 @@ def test_link_repl_func_input_arg(
# that can be anything

# Falsy values got short circuited by urljoin() and never raises
@settings(max_examples=500)
@settings(suppress_health_check=[HealthCheck.too_slow], max_examples=500)
@given(t=_st.all_instances_except_of_type(str, NoneType).filter(bool))
@pytest.mark.slow
def test_base_href(
Expand Down
8 changes: 4 additions & 4 deletions tests/runtime/test_attrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_valid_key_type(self, disposable_attrib: _Attrib, k: _AttrName) -> None:
disposable_attrib[k] = "bar"
del disposable_attrib[k]

@settings(max_examples=500)
@settings(suppress_health_check=[HealthCheck.too_slow], max_examples=500)
@given(
v=_st.all_instances_except_of_type(
*attr_value_types.allow, *attr_value_types.skip
Expand Down Expand Up @@ -137,7 +137,7 @@ class TestMethodHasKey:
def test_signature(self) -> None:
pass

@settings(max_examples=500)
@settings(suppress_health_check=[HealthCheck.too_slow], max_examples=500)
@given(
k=_st.all_instances_except_of_type(
*attr_name_types.allow, *attr_name_types.skip
Expand All @@ -162,7 +162,7 @@ class TestMethodGet:
def test_signature(self) -> None:
pass

@settings(max_examples=500)
@settings(suppress_health_check=[HealthCheck.too_slow], max_examples=500)
@given(
k=_st.all_instances_except_of_type(
*attr_name_types.allow, *attr_name_types.skip
Expand Down Expand Up @@ -198,7 +198,7 @@ def test_signature(self, xml2_root: _Element) -> None:
with pytest.raises(TypeError, match="pop expected at most 2 arguments"):
xml2_root.attrib.pop("foo", 0, 1) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]

@settings(max_examples=500)
@settings(suppress_health_check=[HealthCheck.too_slow], max_examples=500)
@given(
k=_st.all_instances_except_of_type(
*attr_name_types.allow, *attr_name_types.skip
Expand Down

0 comments on commit 683d933

Please sign in to comment.