From 4a0569e97f1c276e7550caf891abcfecbd125a6d Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 11 Feb 2021 13:48:31 +1100 Subject: [PATCH] Changed zero length assertions to falsy --- Tests/test_bmp_reference.py | 2 +- Tests/test_file_dcx.py | 4 ++-- Tests/test_file_fli.py | 4 ++-- Tests/test_file_gif.py | 4 ++-- Tests/test_file_icns.py | 2 +- Tests/test_file_im.py | 4 ++-- Tests/test_file_jpeg.py | 2 +- Tests/test_file_mpo.py | 4 ++-- Tests/test_file_png.py | 2 +- Tests/test_file_psd.py | 4 ++-- Tests/test_file_spider.py | 4 ++-- Tests/test_file_tar.py | 4 ++-- Tests/test_file_tiff.py | 4 ++-- Tests/test_file_webp.py | 2 +- Tests/test_image.py | 2 +- Tests/test_numpy.py | 2 +- 16 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Tests/test_bmp_reference.py b/Tests/test_bmp_reference.py index 46fe1750f..99e16391a 100644 --- a/Tests/test_bmp_reference.py +++ b/Tests/test_bmp_reference.py @@ -28,7 +28,7 @@ def test_bad(): pass # Assert that there is no unclosed file warning - assert len(record) == 0 + assert not record def test_questionable(): diff --git a/Tests/test_file_dcx.py b/Tests/test_file_dcx.py index ec399d3ae..58d5cbf1a 100644 --- a/Tests/test_file_dcx.py +++ b/Tests/test_file_dcx.py @@ -36,7 +36,7 @@ def test_closed_file(): im.load() im.close() - assert len(record) == 0 + assert not record def test_context_manager(): @@ -44,7 +44,7 @@ def test_context_manager(): with Image.open(TEST_FILE) as im: im.load() - assert len(record) == 0 + assert not record def test_invalid_file(): diff --git a/Tests/test_file_fli.py b/Tests/test_file_fli.py index 43ae9b0e0..1d02b5195 100644 --- a/Tests/test_file_fli.py +++ b/Tests/test_file_fli.py @@ -43,7 +43,7 @@ def test_closed_file(): im.load() im.close() - assert len(record) == 0 + assert not record def test_context_manager(): @@ -51,7 +51,7 @@ def test_context_manager(): with Image.open(static_test_file) as im: im.load() - assert len(record) == 0 + assert not record def test_tell(): diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py index adbc8c6aa..f3414647f 100644 --- a/Tests/test_file_gif.py +++ b/Tests/test_file_gif.py @@ -43,7 +43,7 @@ def test_closed_file(): im.load() im.close() - assert len(record) == 0 + assert not record def test_context_manager(): @@ -51,7 +51,7 @@ def test_context_manager(): with Image.open(TEST_GIF) as im: im.load() - assert len(record) == 0 + assert not record def test_invalid_file(): diff --git a/Tests/test_file_icns.py b/Tests/test_file_icns.py index 04d17ccf5..37898d0bd 100644 --- a/Tests/test_file_icns.py +++ b/Tests/test_file_icns.py @@ -21,7 +21,7 @@ def test_sanity(): # Assert that there is no unclosed file warning with pytest.warns(None) as record: im.load() - assert len(record) == 0 + assert not record assert im.mode == "RGBA" assert im.size == (1024, 1024) diff --git a/Tests/test_file_im.py b/Tests/test_file_im.py index b736c3aa6..f1d75465d 100644 --- a/Tests/test_file_im.py +++ b/Tests/test_file_im.py @@ -40,7 +40,7 @@ def test_closed_file(): im.load() im.close() - assert len(record) == 0 + assert not record def test_context_manager(): @@ -48,7 +48,7 @@ def test_context_manager(): with Image.open(TEST_IM) as im: im.load() - assert len(record) == 0 + assert not record def test_tell(): diff --git a/Tests/test_file_jpeg.py b/Tests/test_file_jpeg.py index 435ecbaa7..eff0c0eb1 100644 --- a/Tests/test_file_jpeg.py +++ b/Tests/test_file_jpeg.py @@ -733,7 +733,7 @@ class TestFileJpeg: out = str(tmp_path / "out.jpg") with pytest.warns(None) as record: im.save(out, exif=exif) - assert len(record) == 0 + assert not record with Image.open(out) as reloaded: assert reloaded.getexif()[282] == 180 diff --git a/Tests/test_file_mpo.py b/Tests/test_file_mpo.py index ad11c3d5d..c5756649e 100644 --- a/Tests/test_file_mpo.py +++ b/Tests/test_file_mpo.py @@ -46,7 +46,7 @@ def test_closed_file(): im.load() im.close() - assert len(record) == 0 + assert not record def test_context_manager(): @@ -54,7 +54,7 @@ def test_context_manager(): with Image.open(test_files[0]) as im: im.load() - assert len(record) == 0 + assert not record def test_app(): diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index 16b461f30..26181fb8a 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -326,7 +326,7 @@ class TestFilePng: # Assert that there is no unclosed file warning with pytest.warns(None) as record: im.verify() - assert len(record) == 0 + assert not record with Image.open(TEST_PNG_FILE) as im: im.load() diff --git a/Tests/test_file_psd.py b/Tests/test_file_psd.py index eb2d94cd2..37d807c51 100644 --- a/Tests/test_file_psd.py +++ b/Tests/test_file_psd.py @@ -34,7 +34,7 @@ def test_closed_file(): im.load() im.close() - assert len(record) == 0 + assert not record def test_context_manager(): @@ -42,7 +42,7 @@ def test_context_manager(): with Image.open(test_file) as im: im.load() - assert len(record) == 0 + assert not record def test_invalid_file(): diff --git a/Tests/test_file_spider.py b/Tests/test_file_spider.py index c7ed91f0d..dc90201cf 100644 --- a/Tests/test_file_spider.py +++ b/Tests/test_file_spider.py @@ -33,7 +33,7 @@ def test_closed_file(): im.load() im.close() - assert len(record) == 0 + assert not record def test_context_manager(): @@ -41,7 +41,7 @@ def test_context_manager(): with Image.open(TEST_FILE) as im: im.load() - assert len(record) == 0 + assert not record def test_save(tmp_path): diff --git a/Tests/test_file_tar.py b/Tests/test_file_tar.py index 39356c9ee..b38727fb9 100644 --- a/Tests/test_file_tar.py +++ b/Tests/test_file_tar.py @@ -35,7 +35,7 @@ def test_close(): tar = TarIO.TarIO(TEST_TAR_FILE, "hopper.jpg") tar.close() - assert len(record) == 0 + assert not record def test_contextmanager(): @@ -43,4 +43,4 @@ def test_contextmanager(): with TarIO.TarIO(TEST_TAR_FILE, "hopper.jpg"): pass - assert len(record) == 0 + assert not record diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index f378666ad..f0dc6ea2d 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -64,14 +64,14 @@ class TestFileTiff: im.load() im.close() - assert len(record) == 0 + assert not record def test_context_manager(self): with pytest.warns(None) as record: with Image.open("Tests/images/multipage.tiff") as im: im.load() - assert len(record) == 0 + assert not record def test_mac_tiff(self): # Read RGBa images from macOS [@PIL136] diff --git a/Tests/test_file_webp.py b/Tests/test_file_webp.py index 56c163aab..c4fd08437 100644 --- a/Tests/test_file_webp.py +++ b/Tests/test_file_webp.py @@ -147,7 +147,7 @@ class TestFileWebp: temp_file = str(tmp_path / "temp.webp") with pytest.warns(None) as record: image.save(temp_file) - assert len(record) == 0 + assert not record def test_file_pointer_could_be_reused(self): file_path = "Tests/images/hopper.webp" diff --git a/Tests/test_image.py b/Tests/test_image.py index 13ab8b7bf..41cafaccb 100644 --- a/Tests/test_image.py +++ b/Tests/test_image.py @@ -638,7 +638,7 @@ class TestImage: with Image.open(test_file) as im: with pytest.warns(None) as record: im.save(temp_file) - assert len(record) == 0 + assert not record def test_load_on_nonexclusive_multiframe(self): with open("Tests/images/frozenpond.mpo", "rb") as fp: diff --git a/Tests/test_numpy.py b/Tests/test_numpy.py index 42c7a9281..550d02eea 100644 --- a/Tests/test_numpy.py +++ b/Tests/test_numpy.py @@ -236,4 +236,4 @@ def test_no_resource_warning_for_numpy_array(): # Act/Assert with pytest.warns(None) as record: array(im) - assert len(record) == 0 + assert not record