mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-10-30 07:27:49 +03:00 
			
		
		
		
	Convert test_decompression_bomb.py to use unittest module
This commit is contained in:
		
							parent
							
								
									46abe78b77
								
							
						
					
					
						commit
						7b3e242f09
					
				|  | @ -1,37 +1,40 @@ | ||||||
| from tester import * | from helper import unittest, PillowTestCase, tearDownModule | ||||||
| 
 | 
 | ||||||
| from PIL import Image | from PIL import Image | ||||||
| 
 | 
 | ||||||
| test_file = "Images/lena.ppm" | test_file = "Images/lena.ppm" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_no_warning_small_file(): | class TestDecompressionBomb(PillowTestCase): | ||||||
|  | 
 | ||||||
|  |     def test_no_warning_small_file(self): | ||||||
|         # Implicit assert: no warning. |         # Implicit assert: no warning. | ||||||
|         # A warning would cause a failure. |         # A warning would cause a failure. | ||||||
|         Image.open(test_file) |         Image.open(test_file) | ||||||
| 
 | 
 | ||||||
| 
 |     def test_no_warning_no_limit(self): | ||||||
| def test_no_warning_no_limit(): |  | ||||||
|         # Arrange |         # Arrange | ||||||
|         # Turn limit off |         # Turn limit off | ||||||
|         Image.MAX_IMAGE_PIXELS = None |         Image.MAX_IMAGE_PIXELS = None | ||||||
|     assert_equal(Image.MAX_IMAGE_PIXELS, None) |         self.assertEqual(Image.MAX_IMAGE_PIXELS, None) | ||||||
| 
 | 
 | ||||||
|         # Act / Assert |         # Act / Assert | ||||||
|         # Implicit assert: no warning. |         # Implicit assert: no warning. | ||||||
|         # A warning would cause a failure. |         # A warning would cause a failure. | ||||||
|         Image.open(test_file) |         Image.open(test_file) | ||||||
| 
 | 
 | ||||||
| 
 |     def test_warning(self): | ||||||
| def test_warning(): |  | ||||||
|         # Arrange |         # Arrange | ||||||
|         # Set limit to a low, easily testable value |         # Set limit to a low, easily testable value | ||||||
|         Image.MAX_IMAGE_PIXELS = 10 |         Image.MAX_IMAGE_PIXELS = 10 | ||||||
|     assert_equal(Image.MAX_IMAGE_PIXELS, 10) |         self.assertEqual(Image.MAX_IMAGE_PIXELS, 10) | ||||||
| 
 | 
 | ||||||
|         # Act / Assert |         # Act / Assert | ||||||
|     assert_warning( |         self.assert_warning( | ||||||
|         DecompressionBombWarning, |             Image.DecompressionBombWarning, | ||||||
|             lambda: Image.open(test_file)) |             lambda: Image.open(test_file)) | ||||||
| 
 | 
 | ||||||
|  | if __name__ == '__main__': | ||||||
|  |     unittest.main() | ||||||
|  | 
 | ||||||
| # End of file | # End of file | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user