Adapt conftest.py
# no matter how it is invoked within the source tree.
import os
import pytest
+import matplotlib
import numpy as np
import astropy.units as u
from astropy.time import Time
-from pytest_astropy_header.display import PYTEST_HEADER_MODULES
+from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS
from gammapy.data import GTI
from gammapy.datasets import SpectrumDataset
from gammapy.maps import MapAxis, RegionNDMap
@@ -21,6 +22,12 @@ from gammapy.modeling.models import (
# TODO: activate this again and handle deprecations in the code
# enable_deprecations_as_exceptions(warnings_to_ignore_entire_module=["iminuit", "naima"])
+def pytest_configure(config):
+ """Print some info ..."""
+ from gammapy.utils.testing import has_data
+
+ config.option.astropy_header = True
+
# Declare for which packages version numbers should be displayed
# when running the tests
PYTEST_HEADER_MODULES["cython"] = "cython"
@@ -33,13 +40,6 @@ PYTEST_HEADER_MODULES["sherpa"] = "sherpa"
PYTEST_HEADER_MODULES["gammapy"] = "gammapy"
PYTEST_HEADER_MODULES["naima"] = "naima"
-
-def pytest_configure(config):
- """Print some info ..."""
- from gammapy.utils.testing import has_data
-
- config.option.astropy_header = True
-
print("")
print("Gammapy test data availability:")
@@ -51,15 +51,12 @@ def pytest_configure(config):
var = os.environ.get("GAMMAPY_DATA", "not set")
print(f"GAMMAPY_DATA = {var}")
- try:
- # Switch to non-interactive plotting backend to avoid GUI windows
- # popping up while running the tests.
- import matplotlib
-
matplotlib.use("agg")
print('Setting matplotlib backend to "agg" for the tests.')
- except ImportError:
- pass
+
+ from . import __version__
+ packagename = os.path.basename(os.path.dirname(__file__))
+ TESTED_VERSIONS[packagename] = __version__
@pytest.fixture()
