How to use PyVirtualDisplay - 10 common examples

To help you get started, we’ve selected a few PyVirtualDisplay examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ponty / PyVirtualDisplay / tests / test_examples.py View on Github external
def test_lowres():
        with Display():
            p = EasyProcess([python, "-m", "pyvirtualdisplay.examples.lowres"]).start()
            sleep(1)
            assert p.is_alive()
            p.stop()
github ponty / PyVirtualDisplay / tests / test_core.py View on Github external
def test_extra_args():
    # Unrecognized option
    d = Display(extra_args=["willcrash"])
    with pytest.raises(XStartError):
        d.start()

    with Display():
        # -c                     turns off key-click
        with Display(visible=True, extra_args=["-c"]) as d:
            assert d.is_alive()
        assert not d.is_alive()

        with XephyrDisplay(extra_args=["-c"]) as d:
            assert d.is_alive()
        assert not d.is_alive()
github ponty / PyVirtualDisplay / tests / test_core.py View on Github external
def test_disp():
    vd = Display().start()
    assert vd.is_alive()

    # d = Display(visible=True).start().sleep(2).stop()
    # .assertEquals(d.return_code, 0)

    d = Display(visible=False).start().stop()
    assert d.return_code == 0

    vd.stop()
    assert not vd.is_alive()
github The-Compiler / pytest-xvfb / pytest_xvfb.py View on Github external
def start(self):
        self._virtual_display = pyvirtualdisplay.Display(
            backend='xvfb', size=(self.width, self.height),
            color_depth=self.colordepth, use_xauth=self.xauth,
            extra_args=self.args)
        self._virtual_display.start()
        self.display = self._virtual_display.display
        assert self._virtual_display.is_alive()
github ponty / PyVirtualDisplay / tests / test_smart.py View on Github external
def test_slowshot_timeout():
    disp = SmartDisplay(visible=False)
    py = Path(__file__).parent / ("slowgui.py")
    proc = EasyProcess([python, py])
    with disp:
        with proc:
            with pytest.raises(DisplayTimeoutError):
                img = disp.waitgrab(timeout=1)
github web-animations / web-animations-js-legacy / tools / python / run-tests.py View on Github external
httpd_thread.daemon = True
httpd_thread.start()


# Start up a virtual display, useful for testing on headless servers.
# -----------------------------------------------------------------------------

VIRTUAL_SIZE = (1024, 2000)

# PhantomJS doesn't need a display
disp = None
if args.virtual and args.browser != "PhantomJS":
    from pyvirtualdisplay.smartdisplay import SmartDisplay

    try:
        disp = SmartDisplay(
            visible=0, bgcolor='black', size=VIRTUAL_SIZE).start()
        atexit.register(disp.stop)
    except:
        if disp:
            disp.stop()
        raise


# Start up the web browser and run the tests.
# ----------------------------------------------------------------------------

from selenium import webdriver
from selenium.common import exceptions as selenium_exceptions
from selenium.webdriver.common.keys import Keys as selenium_keys

driver_arguments = {}
github ponty / PyVirtualDisplay / tests / screenshot2.py View on Github external
from pyvirtualdisplay.smartdisplay import SmartDisplay

logging.basicConfig(level=logging.DEBUG)


backend1 = "wx"
backend2 = "wx"


with SmartDisplay(visible=False, bgcolor="black") as disp:
    disp.pyscreenshot_backend = backend1
    with EasyProcess("xmessage test1"):
        img1 = disp.waitgrab()

with SmartDisplay(visible=False, bgcolor="black") as disp:
    disp.pyscreenshot_backend = backend2
    with EasyProcess("xmessage test2"):
        img2 = disp.waitgrab()

img1.show()
img2.show()
github ponty / PyVirtualDisplay / tests / test_core.py View on Github external
def test_color_xvfb():
    with pytest.raises(XStartError):
        vd = Display(color_depth=99).start().stop()
    vd = Display(color_depth=16).start().stop()
    vd = Display(color_depth=24).start().stop()
    vd = Display(color_depth=8).start().stop()
github ponty / PyVirtualDisplay / tests / test_core.py View on Github external
def test_stop_nostart():
    with pytest.raises(XStartError):
        Display().stop()
github ponty / PyVirtualDisplay / tests / test_core.py View on Github external
def test_is_started():
    #     d = Display()
    #     assert not d._is_started
    #     d.start()
    #     assert d._is_started
    #     d.stop()
    #     assert d._is_started

    # with Display() as d:
    #     assert d._is_started
    # assert d._is_started

    with XvfbDisplay() as d:
        assert d._is_started
    assert d._is_started

    with Display():
        with XephyrDisplay() as d:
            assert d._is_started
        assert d._is_started