Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_xauth():
"""
Test that a Xauthority file is created.
"""
if not xauth.is_installed():
print("This test needs xauth installed")
return
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)
self.display = None
self._is_started = False
helptext = get_helptext(program)
self._has_displayfd = "-displayfd" in helptext
if not self._has_displayfd:
log.debug("-displayfd flag is missing.")
# if check_startup and not has_displayfd:
# check_startup = False
# log.warning(
# program
# + " -displayfd flag is not supported, 'check_startup' parameter has been disabled"
# )
self._check_flags(helptext)
if use_xauth and not xauth.is_installed():
raise xauth.NotFoundError()
self._use_xauth = use_xauth
self._old_xauth = None
self._xauth_filename = None
# self.check_startup = check_startup