Skip to content

Commit

Permalink
mypy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
The-Compiler committed Dec 11, 2023
1 parent be5476b commit d8caa5d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pytest_xvfb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import pytest
import pyvirtualdisplay
import pyvirtualdisplay.display

xvfb_instance = None

Expand Down Expand Up @@ -47,24 +48,24 @@ def __init__(self, config: pytest.Config) -> None:
self.args = config.getini("xvfb_args") or []
self.xauth = config.getini("xvfb_xauth")
self.backend = config.getoption("--xvfb-backend")
self.display = None
self._virtual_display = None
self.display: int | None = None
self._virtual_display: pyvirtualdisplay.display.Display | None = None

def start(self) -> None:
self._virtual_display = pyvirtualdisplay.Display( # type: ignore[attr-defined]
self._virtual_display = pyvirtualdisplay.display.Display(
backend=self.backend,
size=(self.width, self.height),
color_depth=self.colordepth,
use_xauth=self.xauth,
extra_args=self.args,
)
assert self._virtual_display is not None # mypy
self._virtual_display.start()
self.display = self._virtual_display.display
assert self._virtual_display.is_alive()

def stop(self) -> None:
if self.display is not None: # starting worked
assert self._virtual_display is not None # mypy
self._virtual_display.stop()


Expand Down

0 comments on commit d8caa5d

Please sign in to comment.