{"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":"python","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,"search_vec":"'0.2.2':54 'astropi':3,38,67,70 'astropy-rel':37 'current':51 'cycl':64 'depend':22 'design':43 'develop':63 'diagnost':13,74 'header':4,25,73 'includ':12 'inform':14 'instal':19 'need':61 'optim':33 'output':29 'packag':49 'plugin':7,72 'primarili':32 'project':40,68 'provid':8 'pytest':2,6,69 'pytest-astropy-head':1 'python':18 'relat':39 'releas':56 'select':21 'system':17 'test':28,71 'tie':58 'typic':57 'usabl':46 'use':35 'version':52 'way':10","created_at":"2026-04-15T18:44:39.276825+00:00","updated_at":"2026-04-15T18:44:39.276825+00:00","problems":[],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.2.2","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/astropy/pytest-astropy-header","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pytest-astropy-header/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}