Registry / testing / pytest-astropy-header

pytest-astropy-header

JSON →
library0.2.2pypypi✓ verified 89d ago

This pytest plugin provides a way to include diagnostic information about the system, Python installation, and select dependencies in the header of the test output. It is primarily optimized for use with Astropy-related projects but is designed to be usable with any package. The current version is 0.2.2, with releases typically tied to the needs and development cycle of the Astropy project.

pip install pytest-astropy-header
INSTALL
IMPORT
SIG · PYTEST-ASTROPY-HEA
P
pytest-astropy-header
testingpythonv0.2.2
Install
2.6s avg
Import
10ms
Disk
29MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.2.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.010s · 30.8MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 2.6s · import 0.011s · 31MB
29MB installed
● package 29MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PYTEST_HEADER_MODULES, TESTED_VERSIONS
✓ from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS
✗ from astropy.tests.plugins.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS
The header plugin was moved out of `astropy.tests.plugins.display` into its own package around Astropy v4.0. Old import paths will fail.

To enable and customize `pytest-astropy-header`, you typically place configuration in your project's `conftest.py` file. The plugin automatically registers when installed, but explicit configuration in `pytest_configure` ensures robust activation and allows for customization of the displayed package versions and modules.

# conftest.py in your project's root or test directory import os from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS def pytest_configure(config): # Ensure the astropy header is enabled config.option.astropy_header = True # Customize modules shown in the header # Example: Remove 'Pandas' from default, add 'scikit-image' # The key is the display name, value is the module import name if 'Pandas' in PYTEST_HEADER_MODULES: PYTEST_HEADER_MODULES.pop('Pandas') PYTEST_HEADER_MODULES['Scikit-image'] = 'skimage' # Customize package versions shown in the header # For a hypothetical 'mypackage' (replace with your package's actual import) try: import mypackage TESTED_VERSIONS['mypackage'] = mypackage.__version__ except ImportError: TESTED_VERSIONS['mypackage'] = 'not installed' # To run tests and see the header, simply execute pytest from your terminal: # pytest
Debug
Known issues
breakingThe header plugin was moved from `astropy.tests.plugins.display` to `pytest_astropy_header` as a standalone package. If your `conftest.py` or other test configuration still uses the old `astropy` import path, it will break when upgrading to Astropy v4.0+ or newer versions of `pytest-astropy-header`.
fix
Update your import statements in `conftest.py` from `from astropy.tests.plugins.display import ...` to `from pytest_astropy_header.display import ...`.
affects: Astropy >= 4.0, pytest-astropy-header (all versions)
gotcha`pytest-astropy-header` explicitly does not support `astropy < 4`. Using it with older Astropy versions may lead to unexpected behavior or errors.
fix
Ensure that your project's `astropy` dependency is version 4.0 or newer when using `pytest-astropy-header`.
affects: < 0.2.0 (implicitly, based on Astropy dependency), all versions with Astropy < 4
gotchaCustomizing the modules and versions displayed in the header requires direct modification of `PYTEST_HEADER_MODULES` and `TESTED_VERSIONS` dictionaries within your `conftest.py`'s `pytest_configure` hook. Incorrect keys or values, or attempting to modify them outside this hook, may not yield the desired header output.
fix
Refer to the `quickstart` example for the correct pattern to modify `PYTEST_HEADER_MODULES` and `TESTED_VERSIONS` dictionaries. The dictionary keys for `PYTEST_HEADER_MODULES` should be the desired display name, and values should be the Python module name.
affects: All versions
Upgrade
Version history
0.2.2latest on PyPI · released Sep 6, 2022
Audit
Dependencies
pytestrequiredThis is a pytest plugin and requires pytest to function.
astropyoptionalWhile not a hard runtime dependency for basic functionality, the plugin is optimized for Astropy and has historical ties. Customization often involves Astropy-related test helpers.
Agent activity
12 hits · last 30 days
node
8
Amazon
1
Resources
pytest-astropy-header — pip install pytest-astropy-header · libregistry