Skip to content

Commit

Permalink
Fixed checking that no debug messages were logged
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Nov 16, 2023
1 parent 67e1253 commit 5f33175
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions Tests/test_image.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io
import logging
import os
import shutil
import sys
Expand Down Expand Up @@ -1014,18 +1015,13 @@ def test_fli_overrun2(self):
except OSError as e:
assert str(e) == "buffer overrun when reading image file"

@pytest.fixture(scope="function")
def inject_caplog(self, caplog):
self._caplog = caplog

@pytest.mark.usefixtures("inject_caplog")
def test_close_graceful(self):
def test_close_graceful(self, caplog):
with Image.open("Tests/images/hopper.jpg") as im:
copy = im.copy()
im.close()
copy.close()

assert len(self._caplog.records) == 0
with caplog.at_level(logging.DEBUG):
im.close()
copy.close()
assert len(caplog.records) == 0
assert im.fp is None


Expand Down

0 comments on commit 5f33175

Please sign in to comment.