Skip to content

Commit 6f30b51

Browse files
committed
Fix testing bug for non-Linux platforms.
The mss_impl fixture would add an implicit display= argument, regardless of platform. The (unreleased) code at that time would ignore it, but this code is more strict.
1 parent 605438f commit 6f30b51

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/tests/conftest.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from hashlib import sha256
88
from pathlib import Path
99
from platform import system
10+
from typing import Any
1011
from zipfile import ZipFile
1112

1213
import pytest
@@ -78,7 +79,14 @@ def backend(request: pytest.FixtureRequest) -> str:
7879
def mss_impl(backend: str) -> Callable[..., MSS]:
7980
# We can't just use partial here, since it will read $DISPLAY at the wrong time. This can cause problems,
8081
# depending on just how the fixtures get run.
81-
return lambda *args, **kwargs: MSS(*args, display=os.getenv("DISPLAY"), backend=backend, **kwargs)
82+
def impl(*args: Any, **kwargs: Any) -> MSS:
83+
# I'm not really sure if adding an explicit display is needed anymore. It was in a lot of existing code that
84+
# mss_impl replaced, but it should now be the default at this point. I'll have to investigate.
85+
if system() == "Linux":
86+
kwargs = {"display": os.getenv("DISPLAY")} | kwargs
87+
return MSS(*args, backend=backend, **kwargs)
88+
89+
return impl
8290

8391

8492
@pytest.fixture(autouse=True, scope="session")

0 commit comments

Comments
 (0)