1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
import logging
import os
import sys
from tempfile import TemporaryDirectory
from time import sleep
from easyprocess import EasyProcess
from tutil import has_xvnc, kill_process_tree, prog_check, worker
from pyvirtualdisplay import Display
log = logging.getLogger(__name__)
python = sys.executable
def test_screenshot():
owd = os.getcwd()
with TemporaryDirectory(prefix="pyvirtualdisplay_") as tmpdirname:
try:
os.chdir(tmpdirname)
p = EasyProcess([python, "-m", "pyvirtualdisplay.examples.screenshot"])
p.call()
assert p.return_code == 0
finally:
os.chdir(owd)
def test_headless():
p = EasyProcess([python, "-m", "pyvirtualdisplay.examples.headless"]).start()
sleep(1)
assert p.is_alive()
# p.stop()
kill_process_tree(p)
def test_nested():
with Display():
p = EasyProcess([python, "-m", "pyvirtualdisplay.examples.nested"]).start()
sleep(1)
assert p.is_alive()
# p.stop()
kill_process_tree(p)
if has_xvnc():
def test_vncserver():
if worker() == 0:
p = EasyProcess(
[python, "-m", "pyvirtualdisplay.examples.vncserver"]
).start()
sleep(1)
assert p.is_alive()
# p.stop()
kill_process_tree(p)
if prog_check(["gnumeric", "-help"]):
def test_lowres():
with Display():
p = EasyProcess([python, "-m", "pyvirtualdisplay.examples.lowres"]).start()
sleep(1)
assert p.is_alive()
# p.stop()
kill_process_tree(p)
|