Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed errors when running tests in random order #5533

Merged
merged 2 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Tests/oss-fuzz/fuzz_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def main():
fuzzers.enable_decompressionbomb_error()
atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
atheris.Fuzz()
fuzzers.disable_decompressionbomb_error()


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions Tests/oss-fuzz/fuzz_pillow.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def main():
fuzzers.enable_decompressionbomb_error()
atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
atheris.Fuzz()
fuzzers.disable_decompressionbomb_error()


if __name__ == "__main__":
Expand Down
5 changes: 5 additions & 0 deletions Tests/oss-fuzz/fuzzers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ def enable_decompressionbomb_error():
warnings.simplefilter("error", Image.DecompressionBombWarning)


def disable_decompressionbomb_error():
ImageFile.LOAD_TRUNCATED_IMAGES = False
warnings.resetwarnings()


def fuzz_image(data):
# This will fail on some images in the corpus, as we have many
# invalid images in the test suite.
Expand Down
2 changes: 2 additions & 0 deletions Tests/oss-fuzz/test_fuzzers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def test_fuzz_images(path):
):
# Known Image.* exceptions
assert True
finally:
fuzzers.disable_decompressionbomb_error()


@pytest.mark.parametrize(
Expand Down
3 changes: 1 addition & 2 deletions Tests/test_decompression_bomb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@


class TestDecompressionBomb:
@classmethod
def teardown_class(cls):
def teardown_method(self, method):
Image.MAX_IMAGE_PIXELS = ORIGINAL_LIMIT

def test_no_warning_small_file(self):
Expand Down