././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1576680853.525753 pytest-astropy-header-0.1.2/0000755000077000000240000000000000000000000015706 5ustar00tomstaff00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1570472025.0 pytest-astropy-header-0.1.2/.gitignore0000644000077000000240000000107600000000000017702 0ustar00tomstaff00000000000000# Compiled files *.py[cod] *.a *.o *.so *.pyd __pycache__ # Ignore .c files by default to avoid including generated code. If you want to # add a non-generated .c extension, use `git add -f filename.c`. *.c # Other generated files MANIFEST # Sphinx _build _generated docs/api docs/generated # Packages/installer info *.egg *.egg-info dist build eggs .eggs parts bin var sdist develop-eggs .installed.cfg distribute-*.tar.gz # Other .cache .tox .*.swp .*.swo *~ .project .pydevproject .settings .coverage cover htmlcov .pytest_cache # Mac OSX .DS_Store # PyCharm .idea ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1575555542.0 pytest-astropy-header-0.1.2/.travis.yml0000644000077000000240000000257700000000000020032 0ustar00tomstaff00000000000000# We set the language to c because python isn't supported on the MacOS X nodes # on Travis. However, the language ends up being irrelevant anyway, since we # install Python ourselves using conda. language: c os: - linux - windows # Use Travis' container-based architecture sudo: false env: global: # The following versions are the 'default' for tests, unless # overidden underneath. They are defined here in order to save having # to repeat them for all configurations. - PYTHON_VERSION=3.7 - PYTEST_VERSION=4 - PYTEST_COMMAND='pytest' - NUMPY_VERSION=stable - CONDA_DEPENDENCIES='astropy' matrix: - PYTHON_VERSION=2.7 NUMPY_VERSION=1.15 PYTEST_COMMAND='py.test' - PYTHON_VERSION=2.7 NUMPY_VERSION=1.15 - PYTHON_VERSION=3.5 NUMPY_VERSION=1.15 - PYTHON_VERSION=3.6 - PYTHON_VERSION=3.7 PYTEST_VERSION=3.8 - PYTHON_VERSION=3.7 PYTEST_VERSION=3.9 - PYTHON_VERSION=3.7 matrix: include: # Try a run on OSX with latest versions of python and pytest - os: osx env: PYTHON_VERSION=3.7 # Try a run against latest pytest - env: PYTHON_VERSION=3.7 PYTEST_VERSION=5 install: - git clone git://github.com/astropy/ci-helpers.git - source ci-helpers/travis/setup_conda.sh - pip install -e . script: - $PYTEST_COMMAND ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1576680788.0 pytest-astropy-header-0.1.2/CHANGES.rst0000644000077000000240000000045600000000000017515 0ustar00tomstaff000000000000000.1.2 (2019-12-18) ================== - Handle the case where the astropy version is 'unknown'. [#11] - Fix declaration of test dependencies. [#9] 0.1.1 (2019-10-25) ================== - Make plugin not crash if astropy is not installed. [#1] 0.1 (2019-10-25) ================ - Initial release. ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1570472025.0 pytest-astropy-header-0.1.2/LICENSE.rst0000644000077000000240000000272300000000000017526 0ustar00tomstaff00000000000000Copyright (c) 2019, Astropy Developers All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the Astropy Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1570472025.0 pytest-astropy-header-0.1.2/MANIFEST.in0000644000077000000240000000015000000000000017440 0ustar00tomstaff00000000000000include LICENSE.rst include README.rst include CHANGES.rst include setup.cfg global-exclude *.pyc *.o ././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1576680853.5259912 pytest-astropy-header-0.1.2/PKG-INFO0000644000077000000240000001761400000000000017014 0ustar00tomstaff00000000000000Metadata-Version: 2.1 Name: pytest-astropy-header Version: 0.1.2 Summary: pytest plugin to add diagnostic information to the header of the test output Home-page: http://astropy.org Author: The Astropy Developers Author-email: astropy.team@gmail.com License: BSD 3-Clause License Description: ===================== pytest-astropy-header ===================== This plugin package provides a way to include information about the system, Python installation, and select dependencies in the header of the output when running pytest. It can be used with packages that are not affiliated with the Astropy project, but is optimized for use with astropy-related projects. Installation ------------ The ``pytest-astropy-header`` plugin can be installed using ``pip``:: $ pip install pytest-astropy-header It is also possible to install the latest development version from the source repository:: $ git clone https://github.com/astropy/pytest-astropy-header $ cd pytest-astropy-header $ pip install . In either case, the plugin will automatically be registered for use with ``pytest``. User guide ---------- The plugin provided by this package makes it easy to include a header with diagnostic information before running the tests, e.g.:: Running tests in astropy. Date: 2019-09-02T23:33:43 Platform: Darwin-18.7.0-x86_64-i386-64bit Executable: /Users/tom/python/dev/bin/python3.7 Full Python Version: 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52) [Clang 6.0 (clang-600.0.57)] encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8 byteorder: little float info: dig: 15, mant_dig: 15 Package versions: numpy: 1.16.4 scipy: 1.3.0 matplotlib: 3.1.1 h5py: 2.9.0 pandas: 0.24.2 astropy: 4.0.dev25634 Using Astropy options: remote_data: none. The most robust way to enable the plugin in a way that will work regardless of how the tests are run (e.g. via ``python setup.py test``, ``pytest``, or ``package.test()``) is to add the following to a ``conftest.py`` file that is inside your package:: def pytest_configure(config): config.option.astropy_header = True By default, a few packages will be shown, but you may want to customize how the packages appear. As for enabling the plugin, the most robust way to do this to be compatible with different astropy versions is via the ``conftest.py`` file:: from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS def pytest_configure(config): config.option.astropy_header = True PYTEST_HEADER_MODULES.pop('Pandas') PYTEST_HEADER_MODULES['scikit-image'] = 'skimage' The key to ``PYTEST_HEADER_MODULES`` should be the name that will be displayed in the header, and the value should be the name of the Python module. Migrating from the astropy header plugin to pytest-astropy ---------------------------------------------------------- Before the v4.0 release of the core astropy package, the plugin that handles the header of the testing output described above lived in ``astropy.tests.plugins.display``. A few steps are now needed to update packages to make sure that only the pytest-astropy version is used instead. These should be done in addition to the configuration mentioned in the previous section. First, you should be able to significantly simplify the ``conftest.py`` file by replacing e.g.:: from astropy.version import version as astropy_version if astropy_version < '3.0': # With older versions of Astropy, we actually need to import the pytest # plugins themselves in order to make them discoverable by pytest. from astropy.tests.pytest_plugins import * else: # As of Astropy 3.0, the pytest plugins provided by Astropy are # automatically made available when Astropy is installed. This means it's # not necessary to import them here, but we still need to import global # variables that are used for configuration. from astropy.tests.plugins.display import (pytest_report_header, PYTEST_HEADER_MODULES, TESTED_VERSIONS) # Customize the following lines to add/remove entries from # the list of packages for which version numbers are displayed when running # the tests. Making it pass for KeyError is essential in some cases when # the package uses other astropy affiliated packages. try: PYTEST_HEADER_MODULES['Astropy'] = 'astropy' del PYTEST_HEADER_MODULES['h5py'] except KeyError: pass # This is to figure out the package version, rather than # using Astropy's from .version import version, astropy_helpers_version packagename = os.path.basename(os.path.dirname(__file__)) TESTED_VERSIONS[packagename] = version TESTED_VERSIONS['astropy_helpers'] = astropy_helpers_version with e.g.:: import os from astropy.version import version as astropy_version if astropy_version < '3.0': from astropy.tests.pytest_plugins import * del pytest_report_header else: from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS def pytest_configure(config): config.option.astropy_header = True PYTEST_HEADER_MODULES.pop('Pandas', None) PYTEST_HEADER_MODULES['scikit-image'] = 'skimage' from .version import version, astropy_helpers_version packagename = os.path.basename(os.path.dirname(__file__)) TESTED_VERSIONS[packagename] = version TESTED_VERSIONS['astropy_helpers'] = astropy_helpers_version Note that while you will need to use a recent version of pytest-astropy for this to work, it should work with Astropy 2.0 onwards without requiring all the ``try...except`` for imports. Next check all of your ``conftest.py`` files and be sure to remove the old plugin from lists such as:: pytest_plugins = [ 'astropy.tests.plugins.display', ] Development Status ------------------ Questions, bug reports, and feature requests can be submitted on `github`_. .. _github: https://github.com/astropy/pytest-astropy License ------- This package is licensed under a 3-clause BSD style license - see the ``LICENSE.rst`` file. Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Intended Audience :: Developers Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: BSD License Provides-Extra: test ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1570472081.0 pytest-astropy-header-0.1.2/README.rst0000644000077000000240000001363300000000000017403 0ustar00tomstaff00000000000000===================== pytest-astropy-header ===================== This plugin package provides a way to include information about the system, Python installation, and select dependencies in the header of the output when running pytest. It can be used with packages that are not affiliated with the Astropy project, but is optimized for use with astropy-related projects. Installation ------------ The ``pytest-astropy-header`` plugin can be installed using ``pip``:: $ pip install pytest-astropy-header It is also possible to install the latest development version from the source repository:: $ git clone https://github.com/astropy/pytest-astropy-header $ cd pytest-astropy-header $ pip install . In either case, the plugin will automatically be registered for use with ``pytest``. User guide ---------- The plugin provided by this package makes it easy to include a header with diagnostic information before running the tests, e.g.:: Running tests in astropy. Date: 2019-09-02T23:33:43 Platform: Darwin-18.7.0-x86_64-i386-64bit Executable: /Users/tom/python/dev/bin/python3.7 Full Python Version: 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52) [Clang 6.0 (clang-600.0.57)] encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8 byteorder: little float info: dig: 15, mant_dig: 15 Package versions: numpy: 1.16.4 scipy: 1.3.0 matplotlib: 3.1.1 h5py: 2.9.0 pandas: 0.24.2 astropy: 4.0.dev25634 Using Astropy options: remote_data: none. The most robust way to enable the plugin in a way that will work regardless of how the tests are run (e.g. via ``python setup.py test``, ``pytest``, or ``package.test()``) is to add the following to a ``conftest.py`` file that is inside your package:: def pytest_configure(config): config.option.astropy_header = True By default, a few packages will be shown, but you may want to customize how the packages appear. As for enabling the plugin, the most robust way to do this to be compatible with different astropy versions is via the ``conftest.py`` file:: from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS def pytest_configure(config): config.option.astropy_header = True PYTEST_HEADER_MODULES.pop('Pandas') PYTEST_HEADER_MODULES['scikit-image'] = 'skimage' The key to ``PYTEST_HEADER_MODULES`` should be the name that will be displayed in the header, and the value should be the name of the Python module. Migrating from the astropy header plugin to pytest-astropy ---------------------------------------------------------- Before the v4.0 release of the core astropy package, the plugin that handles the header of the testing output described above lived in ``astropy.tests.plugins.display``. A few steps are now needed to update packages to make sure that only the pytest-astropy version is used instead. These should be done in addition to the configuration mentioned in the previous section. First, you should be able to significantly simplify the ``conftest.py`` file by replacing e.g.:: from astropy.version import version as astropy_version if astropy_version < '3.0': # With older versions of Astropy, we actually need to import the pytest # plugins themselves in order to make them discoverable by pytest. from astropy.tests.pytest_plugins import * else: # As of Astropy 3.0, the pytest plugins provided by Astropy are # automatically made available when Astropy is installed. This means it's # not necessary to import them here, but we still need to import global # variables that are used for configuration. from astropy.tests.plugins.display import (pytest_report_header, PYTEST_HEADER_MODULES, TESTED_VERSIONS) # Customize the following lines to add/remove entries from # the list of packages for which version numbers are displayed when running # the tests. Making it pass for KeyError is essential in some cases when # the package uses other astropy affiliated packages. try: PYTEST_HEADER_MODULES['Astropy'] = 'astropy' del PYTEST_HEADER_MODULES['h5py'] except KeyError: pass # This is to figure out the package version, rather than # using Astropy's from .version import version, astropy_helpers_version packagename = os.path.basename(os.path.dirname(__file__)) TESTED_VERSIONS[packagename] = version TESTED_VERSIONS['astropy_helpers'] = astropy_helpers_version with e.g.:: import os from astropy.version import version as astropy_version if astropy_version < '3.0': from astropy.tests.pytest_plugins import * del pytest_report_header else: from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS def pytest_configure(config): config.option.astropy_header = True PYTEST_HEADER_MODULES.pop('Pandas', None) PYTEST_HEADER_MODULES['scikit-image'] = 'skimage' from .version import version, astropy_helpers_version packagename = os.path.basename(os.path.dirname(__file__)) TESTED_VERSIONS[packagename] = version TESTED_VERSIONS['astropy_helpers'] = astropy_helpers_version Note that while you will need to use a recent version of pytest-astropy for this to work, it should work with Astropy 2.0 onwards without requiring all the ``try...except`` for imports. Next check all of your ``conftest.py`` files and be sure to remove the old plugin from lists such as:: pytest_plugins = [ 'astropy.tests.plugins.display', ] Development Status ------------------ Questions, bug reports, and feature requests can be submitted on `github`_. .. _github: https://github.com/astropy/pytest-astropy License ------- This package is licensed under a 3-clause BSD style license - see the ``LICENSE.rst`` file. ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1576680853.521153 pytest-astropy-header-0.1.2/pytest_astropy_header/0000755000077000000240000000000000000000000022327 5ustar00tomstaff00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1576680828.0 pytest-astropy-header-0.1.2/pytest_astropy_header/__init__.py0000644000077000000240000000002600000000000024436 0ustar00tomstaff00000000000000__version__ = '0.1.2' ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1576680695.0 pytest-astropy-header-0.1.2/pytest_astropy_header/display.py0000644000077000000240000001523300000000000024352 0ustar00tomstaff00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This plugin provides customization of the header displayed by pytest for reporting purposes. """ import os import sys import datetime import locale import math from collections import OrderedDict from distutils.version import LooseVersion PYTEST_HEADER_MODULES = OrderedDict([('Numpy', 'numpy'), ('Scipy', 'scipy'), ('Matplotlib', 'matplotlib'), ('h5py', 'h5py'), ('Pandas', 'pandas')]) try: from astropy import __version__ as astropy_version from astropy.tests.helper import ignore_warnings from astropy.utils.introspection import resolve_name except ImportError: ASTROPY_INSTALLED = False else: ASTROPY_INSTALLED = True TESTED_VERSIONS = OrderedDict([('Astropy', astropy_version)]) if astropy_version == 'unknown': # assume developer version ASTROPY_LT_30 = ASTROPY_LT_40 = False else: ASTROPY_LT_30 = LooseVersion(astropy_version) < '3.0' ASTROPY_LT_40 = LooseVersion(astropy_version) < '4.0' # If using a version of astropy that has the display plugin, we make sure that # we use those variables for listing the packages, in case we choose to let # that plugin handle things below (which we do if that plugin is active). if ASTROPY_LT_30: from astropy.tests.pytest_plugins import (PYTEST_HEADER_MODULES, TESTED_VERSIONS) elif ASTROPY_LT_40: from astropy.tests.plugins.display import (PYTEST_HEADER_MODULES, TESTED_VERSIONS) def pytest_addoption(parser): group = parser.getgroup("astropy header options") group.addoption('--astropy-header', action='store_true', help="Show the pytest-astropy header") group.addoption('--astropy-header-packages', default=None, help="Comma-separated list of packages to include in the header") parser.addini('astropy_header', type="bool", help="Show the pytest-astropy header") parser.addini('astropy_header_packages', type='linelist', help="Comma-separated list of packages to include in the header") def pytest_report_header(config): if not ASTROPY_INSTALLED: return # If the astropy display plugin is registered, we stop now and let it # handle the header. if ASTROPY_LT_40 and config.pluginmanager.hasplugin('astropy.tests.plugins.display'): return if not config.getoption("astropy_header") and not config.getini("astropy_header"): return astropy_header_packages_option = config.getoption("astropy_header_packages") astropy_header_packages_ini = config.getini("astropy_header_packages") if astropy_header_packages_option is not None: if isinstance(astropy_header_packages_option, str): astropy_header_packages_option = [x.strip() for x in astropy_header_packages_option.split(',')] packages_to_display = OrderedDict([(x, x) for x in astropy_header_packages_option]) elif len(astropy_header_packages_ini) > 0: if len(astropy_header_packages_ini) == 1: astropy_header_packages_ini = [x.strip() for x in astropy_header_packages_ini[0].split(',')] packages_to_display = OrderedDict([(x, x) for x in astropy_header_packages_ini]) else: packages_to_display = PYTEST_HEADER_MODULES try: stdoutencoding = sys.stdout.encoding or 'ascii' except AttributeError: stdoutencoding = 'ascii' args = config.args # TESTED_VERSIONS can contain the affiliated package version, too if len(TESTED_VERSIONS) > 1: for pkg, version in TESTED_VERSIONS.items(): if pkg not in ['Astropy', 'astropy_helpers']: s = "\nRunning tests with {} version {}.\n".format( pkg, version) else: s = "\nRunning tests with Astropy version {}.\n".format( TESTED_VERSIONS['Astropy']) # Per https://github.com/astropy/astropy/pull/4204, strip the rootdir from # each directory argument if hasattr(config, 'rootdir'): rootdir = str(config.rootdir) if not rootdir.endswith(os.sep): rootdir += os.sep dirs = [arg[len(rootdir):] if arg.startswith(rootdir) else arg for arg in args] else: dirs = args s += "Running tests in {}.\n\n".format(" ".join(dirs)) s += "Date: {}\n\n".format(datetime.datetime.now().isoformat()[:19]) from platform import platform plat = platform() if isinstance(plat, bytes): plat = plat.decode(stdoutencoding, 'replace') s += "Platform: {plat}\n\n".format(plat=plat) s += "Executable: {executable}\n\n".format(executable=sys.executable) s += "Full Python Version: \n{version}\n\n".format(version=sys.version) s += "encodings: sys: {}, locale: {}, filesystem: {}".format( sys.getdefaultencoding(), locale.getpreferredencoding(), sys.getfilesystemencoding()) s += '\n' s += "byteorder: {byteorder}\n".format(byteorder=sys.byteorder) s += "float info: dig: {0.dig}, mant_dig: {0.dig}\n\n".format( sys.float_info) s += "Package versions: \n" for module_display, module_name in packages_to_display.items(): try: with ignore_warnings(DeprecationWarning): module = resolve_name(module_name) except ImportError: s += "{module_display}: not available\n".format(module_display=module_display) else: try: version = module.__version__ except AttributeError: version = 'unknown (no __version__ attribute)' s += "{module_display}: {version}\n".format(module_display=module_display, version=version) # Helpers version if 'astropy_helpers' in TESTED_VERSIONS: astropy_helpers_version = TESTED_VERSIONS['astropy_helpers'] else: try: from astropy.version import astropy_helpers_version except ImportError: astropy_helpers_version = None if astropy_helpers_version: s += "astropy-helpers: {astropy_helpers_version}\n".format(astropy_helpers_version=astropy_helpers_version) s += "\n" special_opts = ["remote_data", "pep8"] opts = [] for op in special_opts: op_value = getattr(config.option, op, None) if op_value: if isinstance(op_value, str): op = ': '.join((op, op_value)) opts.append(op) if opts: s += "Using Astropy options: {}.\n".format(", ".join(opts)) return s ././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1576680853.5248003 pytest-astropy-header-0.1.2/pytest_astropy_header.egg-info/0000755000077000000240000000000000000000000024021 5ustar00tomstaff00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1576680853.0 pytest-astropy-header-0.1.2/pytest_astropy_header.egg-info/PKG-INFO0000644000077000000240000001761400000000000025127 0ustar00tomstaff00000000000000Metadata-Version: 2.1 Name: pytest-astropy-header Version: 0.1.2 Summary: pytest plugin to add diagnostic information to the header of the test output Home-page: http://astropy.org Author: The Astropy Developers Author-email: astropy.team@gmail.com License: BSD 3-Clause License Description: ===================== pytest-astropy-header ===================== This plugin package provides a way to include information about the system, Python installation, and select dependencies in the header of the output when running pytest. It can be used with packages that are not affiliated with the Astropy project, but is optimized for use with astropy-related projects. Installation ------------ The ``pytest-astropy-header`` plugin can be installed using ``pip``:: $ pip install pytest-astropy-header It is also possible to install the latest development version from the source repository:: $ git clone https://github.com/astropy/pytest-astropy-header $ cd pytest-astropy-header $ pip install . In either case, the plugin will automatically be registered for use with ``pytest``. User guide ---------- The plugin provided by this package makes it easy to include a header with diagnostic information before running the tests, e.g.:: Running tests in astropy. Date: 2019-09-02T23:33:43 Platform: Darwin-18.7.0-x86_64-i386-64bit Executable: /Users/tom/python/dev/bin/python3.7 Full Python Version: 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52) [Clang 6.0 (clang-600.0.57)] encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8 byteorder: little float info: dig: 15, mant_dig: 15 Package versions: numpy: 1.16.4 scipy: 1.3.0 matplotlib: 3.1.1 h5py: 2.9.0 pandas: 0.24.2 astropy: 4.0.dev25634 Using Astropy options: remote_data: none. The most robust way to enable the plugin in a way that will work regardless of how the tests are run (e.g. via ``python setup.py test``, ``pytest``, or ``package.test()``) is to add the following to a ``conftest.py`` file that is inside your package:: def pytest_configure(config): config.option.astropy_header = True By default, a few packages will be shown, but you may want to customize how the packages appear. As for enabling the plugin, the most robust way to do this to be compatible with different astropy versions is via the ``conftest.py`` file:: from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS def pytest_configure(config): config.option.astropy_header = True PYTEST_HEADER_MODULES.pop('Pandas') PYTEST_HEADER_MODULES['scikit-image'] = 'skimage' The key to ``PYTEST_HEADER_MODULES`` should be the name that will be displayed in the header, and the value should be the name of the Python module. Migrating from the astropy header plugin to pytest-astropy ---------------------------------------------------------- Before the v4.0 release of the core astropy package, the plugin that handles the header of the testing output described above lived in ``astropy.tests.plugins.display``. A few steps are now needed to update packages to make sure that only the pytest-astropy version is used instead. These should be done in addition to the configuration mentioned in the previous section. First, you should be able to significantly simplify the ``conftest.py`` file by replacing e.g.:: from astropy.version import version as astropy_version if astropy_version < '3.0': # With older versions of Astropy, we actually need to import the pytest # plugins themselves in order to make them discoverable by pytest. from astropy.tests.pytest_plugins import * else: # As of Astropy 3.0, the pytest plugins provided by Astropy are # automatically made available when Astropy is installed. This means it's # not necessary to import them here, but we still need to import global # variables that are used for configuration. from astropy.tests.plugins.display import (pytest_report_header, PYTEST_HEADER_MODULES, TESTED_VERSIONS) # Customize the following lines to add/remove entries from # the list of packages for which version numbers are displayed when running # the tests. Making it pass for KeyError is essential in some cases when # the package uses other astropy affiliated packages. try: PYTEST_HEADER_MODULES['Astropy'] = 'astropy' del PYTEST_HEADER_MODULES['h5py'] except KeyError: pass # This is to figure out the package version, rather than # using Astropy's from .version import version, astropy_helpers_version packagename = os.path.basename(os.path.dirname(__file__)) TESTED_VERSIONS[packagename] = version TESTED_VERSIONS['astropy_helpers'] = astropy_helpers_version with e.g.:: import os from astropy.version import version as astropy_version if astropy_version < '3.0': from astropy.tests.pytest_plugins import * del pytest_report_header else: from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS def pytest_configure(config): config.option.astropy_header = True PYTEST_HEADER_MODULES.pop('Pandas', None) PYTEST_HEADER_MODULES['scikit-image'] = 'skimage' from .version import version, astropy_helpers_version packagename = os.path.basename(os.path.dirname(__file__)) TESTED_VERSIONS[packagename] = version TESTED_VERSIONS['astropy_helpers'] = astropy_helpers_version Note that while you will need to use a recent version of pytest-astropy for this to work, it should work with Astropy 2.0 onwards without requiring all the ``try...except`` for imports. Next check all of your ``conftest.py`` files and be sure to remove the old plugin from lists such as:: pytest_plugins = [ 'astropy.tests.plugins.display', ] Development Status ------------------ Questions, bug reports, and feature requests can be submitted on `github`_. .. _github: https://github.com/astropy/pytest-astropy License ------- This package is licensed under a 3-clause BSD style license - see the ``LICENSE.rst`` file. Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Intended Audience :: Developers Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 Classifier: Operating System :: OS Independent Classifier: License :: OSI Approved :: BSD License Provides-Extra: test ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1576680853.0 pytest-astropy-header-0.1.2/pytest_astropy_header.egg-info/SOURCES.txt0000644000077000000240000000075500000000000025714 0ustar00tomstaff00000000000000.gitignore .travis.yml CHANGES.rst LICENSE.rst MANIFEST.in README.rst setup.cfg setup.py pytest_astropy_header/__init__.py pytest_astropy_header/display.py pytest_astropy_header.egg-info/PKG-INFO pytest_astropy_header.egg-info/SOURCES.txt pytest_astropy_header.egg-info/dependency_links.txt pytest_astropy_header.egg-info/entry_points.txt pytest_astropy_header.egg-info/not-zip-safe pytest_astropy_header.egg-info/requires.txt pytest_astropy_header.egg-info/top_level.txt tests/test_display.py././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1576680853.0 pytest-astropy-header-0.1.2/pytest_astropy_header.egg-info/dependency_links.txt0000644000077000000240000000000100000000000030067 0ustar00tomstaff00000000000000 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1576680853.0 pytest-astropy-header-0.1.2/pytest_astropy_header.egg-info/entry_points.txt0000644000077000000240000000010200000000000027310 0ustar00tomstaff00000000000000[pytest11] pytest_astropy_header = pytest_astropy_header.display ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1576680853.0 pytest-astropy-header-0.1.2/pytest_astropy_header.egg-info/not-zip-safe0000644000077000000240000000000100000000000026247 0ustar00tomstaff00000000000000 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1576680853.0 pytest-astropy-header-0.1.2/pytest_astropy_header.egg-info/requires.txt0000644000077000000240000000010500000000000026415 0ustar00tomstaff00000000000000pytest>=2.8 [test] pytest pytest-cov codecov coverage numpy astropy ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1576680853.0 pytest-astropy-header-0.1.2/pytest_astropy_header.egg-info/top_level.txt0000644000077000000240000000002600000000000026551 0ustar00tomstaff00000000000000pytest_astropy_header ././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1576680853.5269125 pytest-astropy-header-0.1.2/setup.cfg0000644000077000000240000000160500000000000017531 0ustar00tomstaff00000000000000[metadata] name = pytest-astropy-header version = attr:pytest_astropy_header.__version__ description = pytest plugin to add diagnostic information to the header of the test output long_description = file:README.rst author = The Astropy Developers author_email = astropy.team@gmail.com license = BSD 3-Clause License url = http://astropy.org classifiers = Development Status :: 3 - Alpha Intended Audience :: Developers Programming Language :: Python Programming Language :: Python :: 2 Programming Language :: Python :: 3 Operating System :: OS Independent License :: OSI Approved :: BSD License [options] zip_safe = False packages = find: install_requires = pytest>=2.8 [options.extras_require] test = pytest pytest-cov codecov coverage numpy astropy [options.entry_points] pytest11 = pytest_astropy_header = pytest_astropy_header.display [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1570472025.0 pytest-astropy-header-0.1.2/setup.py0000755000077000000240000000067000000000000017426 0ustar00tomstaff00000000000000#!/usr/bin/env python import sys import setuptools from distutils.version import LooseVersion from setuptools import setup # Setuptools 30.3.0 or later is needed for setup.cfg options to be used if LooseVersion(setuptools.__version__) < LooseVersion('30.3.0'): sys.stderr.write("ERROR: sphinx-automodapi requires setuptools 30.3.0 or " "later (found {0})".format(setuptools.__version__)) sys.exit(1) setup() ././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1576680853.5253546 pytest-astropy-header-0.1.2/tests/0000755000077000000240000000000000000000000017050 5ustar00tomstaff00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1576680695.0 pytest-astropy-header-0.1.2/tests/test_display.py0000644000077000000240000001462200000000000022133 0ustar00tomstaff00000000000000import pytest import numpy NUMPY_VERSION = numpy.__version__ pytest_plugins = ['pytester'] def extract_package_version_lines(output): lines = [] in_section = False for line in output.splitlines(): if line.strip() == 'Package versions:': in_section = True elif in_section: if line.strip() == "": break else: lines.append(line) return lines def test_default(testdir, capsys): testdir.inline_run() out, err = capsys.readouterr() assert 'Package versions:' not in out @pytest.mark.parametrize('method', ['cli', 'ini', 'conftest']) def test_enabled(testdir, capsys, method): if method == 'cli': testdir.inline_run("--astropy-header") elif method == 'ini': testdir.makeini(""" [pytest] astropy_header = yes """) testdir.inline_run() elif method == 'conftest': testdir.makeconftest(""" def pytest_configure(config): config.option.astropy_header = True """) testdir.inline_run() out, err = capsys.readouterr() lines = extract_package_version_lines(out) assert len(lines) == 6 assert lines[0].startswith('Numpy: ') assert lines[1].startswith('Scipy: ') assert lines[2].startswith('Matplotlib: ') assert lines[3].startswith('h5py: ') assert lines[4].startswith('Pandas: ') assert lines[5].startswith('astropy-helpers: ') @pytest.mark.parametrize('method', ['ini', 'conftest']) def test_explicit_disable(testdir, capsys, method): if method == 'ini': testdir.makeini(""" [pytest] astropy_header = no """) testdir.inline_run() elif method == 'conftest': testdir.makeconftest(""" def pytest_configure(config): config.option.astropy_header = False """) testdir.inline_run() out, err = capsys.readouterr() assert 'Package versions:' not in out @pytest.mark.parametrize('method', ['cli', 'ini', 'ini_list', 'conftest']) def test_override_package_single(testdir, capsys, method): if method == 'cli': testdir.inline_run("--astropy-header", "--astropy-header-packages=numpy") elif method == 'ini': testdir.makeini(""" [pytest] astropy_header = yes astropy_header_packages = numpy """) testdir.inline_run() elif method == 'ini_list': testdir.makeini(""" [pytest] astropy_header = yes astropy_header_packages = numpy """) testdir.inline_run() elif method == 'conftest': testdir.makeconftest(""" def pytest_configure(config): config.option.astropy_header = True config.option.astropy_header_packages = ['numpy'] """) testdir.inline_run() out, err = capsys.readouterr() lines = extract_package_version_lines(out) assert len(lines) == 2 assert lines[0] == 'numpy: {NUMPY_VERSION}'.format(NUMPY_VERSION=NUMPY_VERSION) assert lines[1].startswith('astropy-helpers: ') @pytest.mark.parametrize('method', ['cli', 'ini', 'ini_list', 'conftest']) def test_override_package_multiple(testdir, capsys, method): if method == 'cli': testdir.inline_run("--astropy-header", "--astropy-header-packages=numpy,pandas") elif method == 'ini': testdir.makeini(""" [pytest] astropy_header = yes astropy_header_packages = numpy, pandas """) testdir.inline_run() elif method == 'ini_list': testdir.makeini(""" [pytest] astropy_header = yes astropy_header_packages = numpy pandas """) testdir.inline_run() elif method == 'conftest': testdir.makeconftest(""" def pytest_configure(config): config.option.astropy_header = True config.option.astropy_header_packages = ['numpy', 'pandas'] """) testdir.inline_run() out, err = capsys.readouterr() print(out) lines = extract_package_version_lines(out) assert len(lines) == 3 assert lines[0] == 'numpy: {NUMPY_VERSION}'.format(NUMPY_VERSION=NUMPY_VERSION) assert lines[1].startswith('pandas') assert lines[2].startswith('astropy-helpers: ') @pytest.mark.parametrize('method', ['cli', 'ini', 'ini_list', 'conftest']) def test_nonexistent(testdir, capsys, method): if method == 'cli': testdir.inline_run("--astropy-header", "--astropy-header-packages=apackagethatdoesnotexist") elif method == 'ini': testdir.makeini(""" [pytest] astropy_header = yes astropy_header_packages = apackagethatdoesnotexist """) testdir.inline_run() elif method == 'ini_list': testdir.makeini(""" [pytest] astropy_header = yes astropy_header_packages = apackagethatdoesnotexist """) testdir.inline_run() elif method == 'conftest': testdir.makeconftest(""" def pytest_configure(config): config.option.astropy_header = True config.option.astropy_header_packages = ['apackagethatdoesnotexist'] """) testdir.inline_run() out, err = capsys.readouterr() lines = extract_package_version_lines(out) assert len(lines) == 2 assert lines[0] == 'apackagethatdoesnotexist: not available' assert lines[1].startswith('astropy-helpers: ') def test_modify_in_conftest(testdir, capsys): testdir.makeconftest(""" from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS def pytest_configure(config): config.option.astropy_header = True PYTEST_HEADER_MODULES.pop('Pandas') PYTEST_HEADER_MODULES['scikit-image'] = 'skimage' TESTED_VERSIONS['fakepackage'] = '1.0.2' """) testdir.inline_run() out, err = capsys.readouterr() assert err == '' lines = extract_package_version_lines(out) assert len(lines) == 6 assert lines[0].startswith('Numpy: ') assert lines[1].startswith('Scipy: ') assert lines[2].startswith('Matplotlib: ') assert lines[3].startswith('h5py: ') assert lines[4].startswith('scikit-image: ') assert lines[5].startswith('astropy-helpers: ') assert 'Running tests with fakepackage version 1.0.2' in out