File: conftest.py

package info (click to toggle)
imbalanced-learn 0.12.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,160 kB
  • sloc: python: 17,221; sh: 481; makefile: 187; javascript: 50
file content (30 lines) | stat: -rw-r--r-- 1,054 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
# This file is here so that when running from the root folder
# ./imblearn is added to sys.path by pytest.
# See https://docs.pytest.org/en/latest/pythonpath.html for more details.
# For example, this allows to build extensions in place and run pytest
# doc/modules/clustering.rst and use imblearn from the local folder
# rather than the one from site-packages.

import os

import numpy as np
import pytest
from sklearn.utils.fixes import parse_version

# use legacy numpy print options to avoid failures due to NumPy 2.+ scalar
# representation
if parse_version(np.__version__) > parse_version("2.0.0"):
    np.set_printoptions(legacy="1.25")


def pytest_runtest_setup(item):
    fname = item.fspath.strpath
    if (
        fname.endswith(os.path.join("keras", "_generator.py"))
        or fname.endswith(os.path.join("tensorflow", "_generator.py"))
        or fname.endswith("miscellaneous.rst")
    ):
        try:
            import tensorflow  # noqa
        except ImportError:
            pytest.skip("The tensorflow package is not installed.")