File: test_with.py

package info (click to toggle)
pyvirtualdisplay 3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 388 kB
  • sloc: python: 1,396; sh: 62; ruby: 39; makefile: 4
file content (55 lines) | stat: -rw-r--r-- 1,547 bytes parent folder | download | duplicates (2)
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
from tutil import has_xvnc, rfbport

from pyvirtualdisplay import Display


def test_with_xvfb():
    with Display(size=(800, 600)) as vd:
        assert vd.is_alive()
        assert vd._backend == "xvfb"
    # assert vd.return_code == 0
    assert not vd.is_alive()

    with Display(visible=False, size=(800, 600)) as vd:
        assert vd.is_alive()
        assert vd._backend == "xvfb"
    # assert vd.return_code == 0
    assert not vd.is_alive()

    with Display(backend="xvfb", size=(800, 600)) as vd:
        assert vd.is_alive()
        assert vd._backend == "xvfb"
    # assert vd.return_code == 0
    assert not vd.is_alive()


def test_with_xephyr():
    with Display() as vd:
        with Display(visible=True, size=(800, 600)) as vd:
            assert vd.is_alive()
            assert vd._backend == "xephyr"
        # assert vd.return_code == 0
        assert not vd.is_alive()

        with Display(backend="xephyr", size=(800, 600)) as vd:
            assert vd.is_alive()
            assert vd._backend == "xephyr"
        # assert vd.return_code == 0
        assert not vd.is_alive()


if has_xvnc():

    def test_with_xvnc():
        with Display(backend="xvnc", size=(800, 600), rfbport=rfbport()) as vd:
            assert vd.is_alive()
            assert vd._backend == "xvnc"
        # assert vd.return_code == 0
        assert not vd.is_alive()


def test_dpi():
    with Display(backend="xvfb", size=(800, 600), dpi=99) as vd:
        assert vd.is_alive()
    # assert vd.return_code == 0
    assert not vd.is_alive()