mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-01 00:17:27 +03:00 
			
		
		
		
	Merge pull request #5533 from radarhere/random
Fixed errors when running tests in random order
This commit is contained in:
		
						commit
						3066c48faa
					
				|  | @ -34,6 +34,7 @@ def main(): | ||||||
|     fuzzers.enable_decompressionbomb_error() |     fuzzers.enable_decompressionbomb_error() | ||||||
|     atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True) |     atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True) | ||||||
|     atheris.Fuzz() |     atheris.Fuzz() | ||||||
|  |     fuzzers.disable_decompressionbomb_error() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|  |  | ||||||
|  | @ -34,6 +34,7 @@ def main(): | ||||||
|     fuzzers.enable_decompressionbomb_error() |     fuzzers.enable_decompressionbomb_error() | ||||||
|     atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True) |     atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True) | ||||||
|     atheris.Fuzz() |     atheris.Fuzz() | ||||||
|  |     fuzzers.disable_decompressionbomb_error() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|  |  | ||||||
|  | @ -10,6 +10,11 @@ def enable_decompressionbomb_error(): | ||||||
|     warnings.simplefilter("error", Image.DecompressionBombWarning) |     warnings.simplefilter("error", Image.DecompressionBombWarning) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | def disable_decompressionbomb_error(): | ||||||
|  |     ImageFile.LOAD_TRUNCATED_IMAGES = False | ||||||
|  |     warnings.resetwarnings() | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def fuzz_image(data): | def fuzz_image(data): | ||||||
|     # This will fail on some images in the corpus, as we have many |     # This will fail on some images in the corpus, as we have many | ||||||
|     # invalid images in the test suite. |     # invalid images in the test suite. | ||||||
|  |  | ||||||
|  | @ -44,6 +44,8 @@ def test_fuzz_images(path): | ||||||
|     ): |     ): | ||||||
|         # Known Image.* exceptions |         # Known Image.* exceptions | ||||||
|         assert True |         assert True | ||||||
|  |     finally: | ||||||
|  |         fuzzers.disable_decompressionbomb_error() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @pytest.mark.parametrize( | @pytest.mark.parametrize( | ||||||
|  |  | ||||||
|  | @ -10,8 +10,7 @@ ORIGINAL_LIMIT = Image.MAX_IMAGE_PIXELS | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class TestDecompressionBomb: | class TestDecompressionBomb: | ||||||
|     @classmethod |     def teardown_method(self, method): | ||||||
|     def teardown_class(cls): |  | ||||||
|         Image.MAX_IMAGE_PIXELS = ORIGINAL_LIMIT |         Image.MAX_IMAGE_PIXELS = ORIGINAL_LIMIT | ||||||
| 
 | 
 | ||||||
|     def test_no_warning_small_file(self): |     def test_no_warning_small_file(self): | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user