File: test_xauth.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 (29 lines) | stat: -rw-r--r-- 804 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
import os

from tutil import prog_check

from pyvirtualdisplay import Display, xauth

if prog_check(["xauth", "-V"]):

    def test_xauth_is_installed():
        assert xauth.is_installed()

    def test_xauth():
        """
        Test that a Xauthority file is created.
        """
        old_xauth = os.getenv("XAUTHORITY")
        display = Display(visible=False, use_xauth=True)
        display.start()
        new_xauth = os.getenv("XAUTHORITY")

        assert new_xauth is not None
        assert os.path.isfile(new_xauth)
        filename = os.path.basename(new_xauth)
        assert filename.startswith("PyVirtualDisplay.")
        assert filename.endswith("Xauthority")

        display.stop()
        assert old_xauth == os.getenv("XAUTHORITY")
        assert not os.path.isfile(new_xauth)