Skip to content

Commit

Permalink
Merge pull request #5533 from radarhere/random
Browse files Browse the repository at this point in the history
Fixed errors when running tests in random order
  • Loading branch information
radarhere authored Jun 14, 2021
2 parents 8f55c95 + 41fc391 commit 3066c48
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
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

0 comments on commit 3066c48

Please sign in to comment.