mirror of
https://github.com/SELinuxProject/setools
synced 2025-04-26 05:09:33 +00:00
tests: Skip GUI tests if key dependencies are missing.
Ignore GUI tests if DISPLAY is not set or PyQt is not available. Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
This commit is contained in:
parent
b43c844f1a
commit
57566d9c72
31
tests/gui/conftest.py
Normal file
31
tests/gui/conftest.py
Normal file
@ -0,0 +1,31 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
import os
|
||||
import pathlib
|
||||
import pytest
|
||||
|
||||
try:
|
||||
import PyQt6
|
||||
have_pyqt6 = True
|
||||
except ImportError:
|
||||
have_pyqt6 = False
|
||||
|
||||
try:
|
||||
import pytestqt
|
||||
have_pqtestqt = True
|
||||
except ImportError:
|
||||
have_pqtestqt = False
|
||||
|
||||
|
||||
def pytest_ignore_collect(collection_path: pathlib.Path, path,
|
||||
config: pytest.Config) -> bool | None:
|
||||
|
||||
"""Ignore GUI tests if DISPLAY is not set or PyQt is not available."""
|
||||
|
||||
xdisp = bool(os.getenv("DISPLAY"))
|
||||
|
||||
# Return True to prevent considering this path for collection.
|
||||
if all((xdisp, have_pyqt6, have_pqtestqt)):
|
||||
return False
|
||||
|
||||
return True
|
Loading…
Reference in New Issue
Block a user