mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-12 17:22:28 +03:00
Run slow tests on valgrind, but without timeout
This commit is contained in:
parent
7e4d8e2f55
commit
cd6a21223c
|
@ -161,6 +161,12 @@ def assert_tuple_approx_equal(
|
|||
pytest.fail(msg + ": " + repr(actuals) + " != " + repr(targets))
|
||||
|
||||
|
||||
def timeout_unless_slower_valgrind(timeout: float) -> pytest.MarkDecorator:
|
||||
if "PILLOW_VALGRIND_TEST" in os.environ:
|
||||
return pytest.mark.pil_noop_mark()
|
||||
return pytest.mark.timeout(timeout)
|
||||
|
||||
|
||||
def skip_unless_feature(feature: str) -> pytest.MarkDecorator:
|
||||
reason = f"{feature} not available"
|
||||
return pytest.mark.skipif(not features.check(feature), reason=reason)
|
||||
|
|
|
@ -13,7 +13,12 @@ import pytest
|
|||
|
||||
from PIL import Image, PdfParser, features
|
||||
|
||||
from .helper import hopper, mark_if_feature_version, skip_unless_feature
|
||||
from .helper import (
|
||||
hopper,
|
||||
mark_if_feature_version,
|
||||
skip_unless_feature,
|
||||
timeout_unless_slower_valgrind,
|
||||
)
|
||||
|
||||
|
||||
def helper_save_as_pdf(tmp_path: Path, mode: str, **kwargs: Any) -> str:
|
||||
|
@ -339,8 +344,7 @@ def test_pdf_append_to_bytesio() -> None:
|
|||
assert len(f.getvalue()) > initial_size
|
||||
|
||||
|
||||
@pytest.mark.timeout(1)
|
||||
@pytest.mark.skipif("PILLOW_VALGRIND_TEST" in os.environ, reason="Valgrind is slower")
|
||||
@timeout_unless_slower_valgrind(1)
|
||||
@pytest.mark.parametrize("newline", (b"\r", b"\n"))
|
||||
def test_redos(newline: bytes) -> None:
|
||||
malicious = b" trailer<<>>" + newline * 3456
|
||||
|
|
|
@ -34,6 +34,7 @@ from .helper import (
|
|||
is_win32,
|
||||
mark_if_feature_version,
|
||||
skip_unless_feature,
|
||||
timeout_unless_slower_valgrind,
|
||||
)
|
||||
|
||||
ElementTree: ModuleType | None
|
||||
|
@ -572,10 +573,7 @@ class TestImage:
|
|||
i = Image.new("RGB", [1, 1])
|
||||
assert isinstance(i.size, tuple)
|
||||
|
||||
@pytest.mark.timeout(0.75)
|
||||
@pytest.mark.skipif(
|
||||
"PILLOW_VALGRIND_TEST" in os.environ, reason="Valgrind is slower"
|
||||
)
|
||||
@timeout_unless_slower_valgrind(0.75)
|
||||
@pytest.mark.parametrize("size", ((0, 100000000), (100000000, 0)))
|
||||
def test_empty_image(self, size: tuple[int, int]) -> None:
|
||||
Image.new("RGB", size)
|
||||
|
|
Loading…
Reference in New Issue
Block a user