Create virtual X display. This function is a no-op unless GITHUB_ACTIONS is set in the environment. Yields: the pyvirtualdisplay object that the browser will be open on
()
| 16 | |
| 17 | @pytest.fixture(scope="session", autouse=True) |
| 18 | def xvfb(): |
| 19 | """Create virtual X display. |
| 20 | |
| 21 | This function is a no-op unless GITHUB_ACTIONS is set in the environment. |
| 22 | |
| 23 | Yields: |
| 24 | the pyvirtualdisplay object that the browser will be open on |
| 25 | """ |
| 26 | if os.environ.get("GITHUB_ACTIONS"): |
| 27 | from pyvirtualdisplay.smartdisplay import ( # pyright: ignore [reportMissingImports] |
| 28 | SmartDisplay, |
| 29 | ) |
| 30 | |
| 31 | global DISPLAY |
| 32 | with SmartDisplay(visible=0, size=XVFB_DIMENSIONS) as DISPLAY: |
| 33 | yield DISPLAY |
| 34 | DISPLAY = None |
| 35 | else: |
| 36 | yield None |
| 37 | |
| 38 | |
| 39 | def pytest_exception_interact(node, call, report): |