skip ImageGrab test on Windows in Docker

This commit is contained in:
nulano 2020-03-01 20:16:29 +00:00
parent a7c3f126ed
commit c09461103a
2 changed files with 20 additions and 1 deletions

View File

@ -282,6 +282,19 @@ def is_win32():
return sys.platform.startswith("win32") return sys.platform.startswith("win32")
def is_win32_docker():
try:
import winreg
key = winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\Control"
)
winreg.QueryValueEx(key, "ContainerType") # fails if not in Docker container
return True
except (ImportError, OSError):
return False
def is_pypy(): def is_pypy():
return hasattr(sys, "pypy_translation_info") return hasattr(sys, "pypy_translation_info")

View File

@ -6,13 +6,19 @@ import pytest
from PIL import Image, ImageGrab from PIL import Image, ImageGrab
from .helper import assert_image, assert_image_equal_tofile, skip_unless_feature from .helper import (
assert_image,
assert_image_equal_tofile,
is_win32_docker,
skip_unless_feature,
)
class TestImageGrab: class TestImageGrab:
@pytest.mark.skipif( @pytest.mark.skipif(
sys.platform not in ("win32", "darwin"), reason="requires Windows or macOS" sys.platform not in ("win32", "darwin"), reason="requires Windows or macOS"
) )
@pytest.mark.skipif(is_win32_docker(), reason="running on headless Windows")
def test_grab(self): def test_grab(self):
for im in [ for im in [
ImageGrab.grab(), ImageGrab.grab(),