File: conftest.py

package info (click to toggle)
setools 4.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,600 kB
  • sloc: python: 24,485; makefile: 14
file content (31 lines) | stat: -rw-r--r-- 659 bytes parent folder | download
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
30
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,
                          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