Fix formatting

This commit is contained in:
Adian Kozlica 2025-03-28 17:18:09 +01:00
parent 722283e819
commit eeb494abf7
2 changed files with 7 additions and 6 deletions

View File

@ -40,7 +40,11 @@ class TestImageGrab:
@pytest.mark.skipif(Image.core.HAVE_XCB, reason="tests missing XCB")
def test_grab_no_xcb(self) -> None:
if sys.platform not in ("win32", "darwin") and not shutil.which("gnome-screenshot") and not shutil.which('spectacle'):
if (
sys.platform not in ("win32", "darwin")
and not shutil.which("gnome-screenshot")
and not shutil.which("spectacle")
):
with pytest.raises(OSError) as e:
ImageGrab.grab()
assert str(e.value).startswith("Pillow was built without XCB support")

View File

@ -77,10 +77,7 @@ def grab(
raise OSError(msg)
size, data = Image.core.grabscreen_x11(display_name)
except OSError:
if (
display_name is None
and sys.platform not in ("darwin", "win32")
):
if display_name is None and sys.platform not in ("darwin", "win32"):
fh, filepath = tempfile.mkstemp(".png")
os.close(fh)
if shutil.which("gnome-screenshot"):
@ -89,7 +86,7 @@ def grab(
subprocess.call(["spectacle", "-n", "-b", "-f", "-o", filepath])
else:
os.unlink(filepath)
raise
raise
im = Image.open(filepath)
im.load()
os.unlink(filepath)