Merge pull request #5533 from radarhere/random

Fixed errors when running tests in random order
This commit is contained in:
Andrew Murray 2021-06-14 22:43:31 +10:00 committed by GitHub
commit 3066c48faa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 2 deletions

View File

@ -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__":

View File

@ -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__":

View File

@ -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.

View File

@ -44,6 +44,8 @@ def test_fuzz_images(path):
):
# Known Image.* exceptions
assert True
finally:
fuzzers.disable_decompressionbomb_error()
@pytest.mark.parametrize(

View File

@ -10,8 +10,7 @@ ORIGINAL_LIMIT = Image.MAX_IMAGE_PIXELS
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):