File: utils.py

package info (click to toggle)
python-qtpy 2.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 924 kB
  • sloc: python: 4,767; sh: 28; makefile: 19
file content (27 lines) | stat: -rw-r--r-- 714 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
"""Utility functions for tests."""

import os

import pytest
from packaging.version import parse


def using_conda():
    return os.environ.get("USE_CONDA", "Yes") == "Yes"


def not_using_conda():
    return os.environ.get("USE_CONDA", "No") == "No"


def pytest_importorskip(module, **kwargs):
    """
    Skip the test if the module cannot be imported.

    This is a wrapper around `pytest.importorskip` to support using it with
    Python 3.7+. The `exc_type` argument was added in `pytest` 8.2.0.
    See spyder-ide/qtpy#485
    """
    if parse(pytest.__version__) < parse("8.2.0"):
        return pytest.importorskip(module, **kwargs)
    return pytest.importorskip(module, **kwargs, exc_type=ImportError)