Do not repeatedly save to the same path

This commit is contained in:
Andrew Murray 2024-10-29 22:21:53 +11:00
parent 2d1d801ec0
commit 624848ff97

View File

@ -543,10 +543,10 @@ class TestFileJpeg:
) )
def test_qtables(self, tmp_path: Path) -> None: def test_qtables(self, tmp_path: Path) -> None:
def _n_qtables_helper(n: int, test_file: str) -> None: def _n_qtables_helper(n: int, test_file: str) -> None:
b = BytesIO()
with Image.open(test_file) as im: with Image.open(test_file) as im:
f = str(tmp_path / "temp.jpg") im.save(b, "JPEG", qtables=[[n] * 64] * n)
im.save(f, qtables=[[n] * 64] * n) with Image.open(b) as im:
with Image.open(f) as im:
assert len(im.quantization) == n assert len(im.quantization) == n
reloaded = self.roundtrip(im, qtables="keep") reloaded = self.roundtrip(im, qtables="keep")
assert im.quantization == reloaded.quantization assert im.quantization == reloaded.quantization