{"id":6826,"library":"pytest-astropy-header","title":"pytest-astropy-header","description":"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.","status":"active","version":"0.2.2","language":"en","source_language":"en","source_url":"https://github.com/astropy/pytest-astropy-header","tags":["pytest","astropy","testing","plugin","header","diagnostics"],"install":[{"cmd":"pip install pytest-astropy-header","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"This is a pytest plugin and requires pytest to function.","package":"pytest","optional":false},{"reason":"While 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.","package":"astropy","optional":true}],"imports":[{"note":"The header plugin was moved out of `astropy.tests.plugins.display` into its own package around Astropy v4.0. Old import paths will fail.","wrong":"from astropy.tests.plugins.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS","symbol":"PYTEST_HEADER_MODULES, TESTED_VERSIONS","correct":"from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS"}],"quickstart":{"code":"# conftest.py in your project's root or test directory\n\nimport os\nfrom pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS\n\ndef pytest_configure(config):\n    # Ensure the astropy header is enabled\n    config.option.astropy_header = True\n\n    # Customize modules shown in the header\n    # Example: Remove 'Pandas' from default, add 'scikit-image'\n    # The key is the display name, value is the module import name\n    if 'Pandas' in PYTEST_HEADER_MODULES:\n        PYTEST_HEADER_MODULES.pop('Pandas')\n    PYTEST_HEADER_MODULES['Scikit-image'] = 'skimage'\n\n    # Customize package versions shown in the header\n    # For a hypothetical 'mypackage' (replace with your package's actual import)\n    try:\n        import mypackage\n        TESTED_VERSIONS['mypackage'] = mypackage.__version__\n    except ImportError:\n        TESTED_VERSIONS['mypackage'] = 'not installed'\n\n# To run tests and see the header, simply execute pytest from your terminal:\n# pytest","lang":"python","description":"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."},"warnings":[{"fix":"Update your import statements in `conftest.py` from `from astropy.tests.plugins.display import ...` to `from pytest_astropy_header.display import ...`.","message":"The 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`.","severity":"breaking","affected_versions":"Astropy >= 4.0, pytest-astropy-header (all versions)"},{"fix":"Ensure that your project's `astropy` dependency is version 4.0 or newer when using `pytest-astropy-header`.","message":"`pytest-astropy-header` explicitly does not support `astropy < 4`. Using it with older Astropy versions may lead to unexpected behavior or errors.","severity":"gotcha","affected_versions":"< 0.2.0 (implicitly, based on Astropy dependency), all versions with Astropy < 4"},{"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.","message":"Customizing 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}