Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-pytest-doctestplus for openSUSE:Factory checked in at 2021-05-03 22:08:06 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pytest-doctestplus (Old) and /work/SRC/openSUSE:Factory/.python-pytest-doctestplus.new.2988 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pytest-doctestplus" Mon May 3 22:08:06 2021 rev:10 rq:889865 version:0.9.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pytest-doctestplus/python-pytest-doctestplus.changes 2020-08-28 23:45:19.935488177 +0200 +++ /work/SRC/openSUSE:Factory/.python-pytest-doctestplus.new.2988/python-pytest-doctestplus.changes 2021-05-03 22:08:18.508455715 +0200 @@ -1,0 +2,9 @@ +Sun May 2 08:42:25 UTC 2021 - Ben Greiner <c...@bnavigator.de> + +- Update to 0.9.0 + * Declare setuptools runtime dependency. [#93] + * Add SHOW_WARNINGS flag to show warnings. [#136] + * Add the doctestplus sphinx extension. [#113] + * Compatibility with pytest>=6.3 [#140, #141] + +------------------------------------------------------------------- Old: ---- pytest-doctestplus-0.8.0.tar.gz New: ---- pytest-doctestplus-0.9.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pytest-doctestplus.spec ++++++ --- /var/tmp/diff_new_pack.Dicf6j/_old 2021-05-03 22:08:19.016453547 +0200 +++ /var/tmp/diff_new_pack.Dicf6j/_new 2021-05-03 22:08:19.020453530 +0200 @@ -1,7 +1,7 @@ # -# spec file for package python-pytest-doctestplus +# spec file for package python-pytest-doctestplus-test # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -27,23 +27,22 @@ %define skip_python2 1 %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-pytest-doctestplus%{psuffix} -Version: 0.8.0 +Version: 0.9.0 Release: 0 Summary: Pytest plugin with advanced doctest features License: BSD-3-Clause URL: https://github.com/astropy/pytest-doctestplus Source: https://files.pythonhosted.org/packages/source/p/pytest-doctestplus/pytest-doctestplus-%{version}.tar.gz +BuildRequires: %{python_module setuptools_scm} BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros -Requires: python-pytest >= 4.0 -Requires: python-six +Requires: python-pytest >= 4.6 +Requires: python-setuptools >= 30.3.0 BuildArch: noarch %if %{with test} -BuildRequires: %{python_module pip} -BuildRequires: %{python_module pytest >= 4.0} -BuildRequires: %{python_module pytest-doctestplus >= %{version}} -BuildRequires: %{python_module six} +BuildRequires: %{python_module pip >= 19.3.1} +BuildRequires: %{python_module pytest-doctestplus = %{version}} %endif %python_subpackages @@ -54,8 +53,9 @@ %prep %setup -q -n pytest-doctestplus-%{version} -# do not change the pytest behaviour for us -rm -f setup.cfg +# https://build.opensuse.org/request/show/889802 +sed -i '/filterwarnings/,/\s+/ { /error/ a \ ignore:.*unclosed file.*:ResourceWarning +}' setup.cfg %build %python_build @@ -70,15 +70,16 @@ %check export LANG=en_US.UTF8 export PY_IGNORE_IMPORTMISMATCH=1 -# README.rst contains Python 3 only imports -%pytest --doctest-plus --doctest-rst -k 'not README.rst' +# -k: inline pytest calls with -We, https://build.opensuse.org/request/show/889802 +%pytest tests/ --doctest-plus --doctest-rst -k "not (test_doctestplus and warnings)" %endif %if !%{with test} %files %{python_files} %doc CHANGES.rst README.rst %license LICENSE.rst -%{python_sitelib}/* +%{python_sitelib}/pytest_doctestplus +%{python_sitelib}/pytest_doctestplus-%{version}*-info %endif %changelog ++++++ pytest-doctestplus-0.8.0.tar.gz -> pytest-doctestplus-0.9.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/.github/workflows/publish.yml new/pytest-doctestplus-0.9.0/.github/workflows/publish.yml --- old/pytest-doctestplus-0.8.0/.github/workflows/publish.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-doctestplus-0.9.0/.github/workflows/publish.yml 2021-01-15 02:19:47.000000000 +0100 @@ -0,0 +1,43 @@ +name: Release + +on: + push: + +jobs: + build-n-publish: + name: Build and publish Python ???? distributions ???? to PyPI + runs-on: ubuntu-latest + if: github.repository == 'astropy/pytest-doctestplus' + + steps: + - uses: actions/checkout@master + with: + fetch-depth: 0 + - uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install python-build and twine + run: python -m pip install build "twine>=3.3" + + - name: Build package + run: python -m build --sdist --wheel . + + - name: List result + run: ls -l dist + + - name: Check long_description + run: python -m twine check --strict dist/* + + - name: Test package + run: | + cd .. + python -m venv testenv + testenv/bin/pip install pytest pytest-doctestplus/dist/*.whl + testenv/bin/pytest pytest-doctestplus/tests --doctest-plus --doctest-rst + + - name: Publish distribution ???? to PyPI + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.pypi_password }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/.github/workflows/python-tests.yml new/pytest-doctestplus-0.9.0/.github/workflows/python-tests.yml --- old/pytest-doctestplus-0.8.0/.github/workflows/python-tests.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-doctestplus-0.9.0/.github/workflows/python-tests.yml 2021-01-15 02:19:47.000000000 +0100 @@ -0,0 +1,64 @@ +name: Run unit tests + +on: + pull_request: + push: + branches: [ master ] + tags: + workflow_dispatch: + schedule: + # Run every Sunday at 03:53 UTC + - cron: 53 3 * * 0 + +jobs: + tests: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + python-version: 3.6 + toxenv: py36-test-pytest46 + - os: windows-latest + python-version: 3.6 + toxenv: py36-test-pytest50 + - os: macos-latest + python-version: 3.7 + toxenv: py37-test-pytest51 + - os: ubuntu-latest + python-version: 3.7 + toxenv: py37-test-pytest52 + - os: windows-latest + python-version: 3.8 + toxenv: py38-test-pytest53 + - os: ubuntu-latest + python-version: 3.8 + toxenv: py38-test-pytest60 + - os: ubuntu-latest + python-version: 3.9 + toxenv: py39-test-pytest61 + - os: macos-latest + python-version: 3.8 + toxenv: py38-test-pytestdev + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Tox + run: python -m pip install tox + - name: Run Tox + run: tox -v -e ${{ matrix.toxenv }} + + # - name: Slack Notification + # uses: 8398a7/action-slack@v3 + # with: + # status: ${{ job.status }} + # env: + # SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} + # if: always() # TODO: cron diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/.gitignore new/pytest-doctestplus-0.9.0/.gitignore --- old/pytest-doctestplus-0.8.0/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-doctestplus-0.9.0/.gitignore 2021-01-15 02:19:47.000000000 +0100 @@ -0,0 +1,63 @@ +# 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 + +# Env +.venv +venv +.env + +# Mac OSX +.DS_Store + +# PyCharm +.idea + +pytest_doctestplus/version.py +pip-wheel-metadata/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/CHANGES.rst new/pytest-doctestplus-0.9.0/CHANGES.rst --- old/pytest-doctestplus-0.8.0/CHANGES.rst 2020-07-31 22:55:19.000000000 +0200 +++ new/pytest-doctestplus-0.9.0/CHANGES.rst 2021-01-15 02:19:47.000000000 +0100 @@ -1,3 +1,14 @@ +0.9.0 (2021-01-14) +================== + +- Declare ``setuptools`` runtime dependency [#93] + +- Add ``SHOW_WARNINGS`` flag to show warnings. [#136] + +- Add the doctestplus sphinx extension. [#113] + +- Compatibility with pytest>=6.3 [#140, #141] + 0.8.0 (2020-07-31) ================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/PKG-INFO new/pytest-doctestplus-0.9.0/PKG-INFO --- old/pytest-doctestplus-0.8.0/PKG-INFO 2020-07-31 23:04:35.411392200 +0200 +++ new/pytest-doctestplus-0.9.0/PKG-INFO 2021-01-15 02:19:55.924952300 +0100 @@ -1,8 +1,8 @@ Metadata-Version: 2.1 Name: pytest-doctestplus -Version: 0.8.0 +Version: 0.9.0 Summary: Pytest plugin with advanced doctest features. -Home-page: https://astropy.org +Home-page: https://github.com/astropy/pytest-doctestplus Author: The Astropy Developers Author-email: astropy.t...@gmail.com License: BSD @@ -16,7 +16,7 @@ been moved to a separate package in order to be of more general use. .. _pytest: https://pytest.org/en/latest/ - .. _astropy: https://astropy.org/en/latest/ + .. _astropy: https://astropy.org/ .. _reStructuredText: https://en.wikipedia.org/wiki/ReStructuredText @@ -57,7 +57,7 @@ $ git clone https://github.com/astropy/pytest-doctestplus $ cd pytest-doctestplus - $ python ./setup.py install + $ pip install . In either case, the plugin will automatically be registered for use with ``pytest``. @@ -155,6 +155,23 @@ >>> np.mean([]) # doctest: +IGNORE_WARNINGS np.nan + Showing warnings + ~~~~~~~~~~~~~~~~ + + If code in a doctest emits a warning and you want to make sure that warning is + shown, you can make use of the ``SHOW_WARNINGS`` flag. This is useful when + warnings are turned into errors by pytest, and also because by default warnings + are printed to stderr. This is the opposite from ``IGNORE_WARNINGS`` so + obviously the two flags should not be used together. For example: + + .. code-block:: python + + >>> import numpy as np + >>> np.mean([]) # doctest: +SHOW_WARNINGS + RuntimeWarning: Mean of empty slice. + RuntimeWarning: invalid value encountered in double_scalars + np.nan + Skipping Tests ~~~~~~~~~~~~~~ @@ -269,12 +286,23 @@ .. _pytest-remotedata: https://github.com/astropy/pytest-remotedata __ pytest-remotedata_ + Sphinx Compatibility + ~~~~~~~~~~~~~~~~~~~~ + + To use the additional directives when building your documentation with sphinx + you may want to enable the sphinx extension which registers these directives + with sphinx. Doing so ensures that sphinx correctly ignores these directives, + running the doctests with sphinx is not supported. To do this, add + ``'pytest_doctestplus.sphinx.doctestplus'`` to your ``extensions`` list in your + ``conf.py`` file. + + Development Status ------------------ - .. image:: https://travis-ci.org/astropy/pytest-doctestplus.svg - :target: https://travis-ci.org/astropy/pytest-doctestplus - :alt: Travis CI Status + .. image:: https://github.com/astropy/pytest-doctestplus/workflows/Run%20unit%20tests/badge.svg + :target: https://github.com/astropy/pytest-doctestplus/actions + :alt: CI Status Questions, bug reports, and feature requests can be submitted on `github`_. @@ -294,6 +322,7 @@ Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/README.rst new/pytest-doctestplus-0.9.0/README.rst --- old/pytest-doctestplus-0.8.0/README.rst 2020-07-31 22:55:19.000000000 +0200 +++ new/pytest-doctestplus-0.9.0/README.rst 2021-01-15 02:19:47.000000000 +0100 @@ -8,7 +8,7 @@ been moved to a separate package in order to be of more general use. .. _pytest: https://pytest.org/en/latest/ -.. _astropy: https://astropy.org/en/latest/ +.. _astropy: https://astropy.org/ .. _reStructuredText: https://en.wikipedia.org/wiki/ReStructuredText @@ -49,7 +49,7 @@ $ git clone https://github.com/astropy/pytest-doctestplus $ cd pytest-doctestplus - $ python ./setup.py install + $ pip install . In either case, the plugin will automatically be registered for use with ``pytest``. @@ -147,6 +147,23 @@ >>> np.mean([]) # doctest: +IGNORE_WARNINGS np.nan +Showing warnings +~~~~~~~~~~~~~~~~ + +If code in a doctest emits a warning and you want to make sure that warning is +shown, you can make use of the ``SHOW_WARNINGS`` flag. This is useful when +warnings are turned into errors by pytest, and also because by default warnings +are printed to stderr. This is the opposite from ``IGNORE_WARNINGS`` so +obviously the two flags should not be used together. For example: + +.. code-block:: python + + >>> import numpy as np + >>> np.mean([]) # doctest: +SHOW_WARNINGS + RuntimeWarning: Mean of empty slice. + RuntimeWarning: invalid value encountered in double_scalars + np.nan + Skipping Tests ~~~~~~~~~~~~~~ @@ -261,12 +278,23 @@ .. _pytest-remotedata: https://github.com/astropy/pytest-remotedata __ pytest-remotedata_ +Sphinx Compatibility +~~~~~~~~~~~~~~~~~~~~ + +To use the additional directives when building your documentation with sphinx +you may want to enable the sphinx extension which registers these directives +with sphinx. Doing so ensures that sphinx correctly ignores these directives, +running the doctests with sphinx is not supported. To do this, add +``'pytest_doctestplus.sphinx.doctestplus'`` to your ``extensions`` list in your +``conf.py`` file. + + Development Status ------------------ -.. image:: https://travis-ci.org/astropy/pytest-doctestplus.svg - :target: https://travis-ci.org/astropy/pytest-doctestplus - :alt: Travis CI Status +.. image:: https://github.com/astropy/pytest-doctestplus/workflows/Run%20unit%20tests/badge.svg + :target: https://github.com/astropy/pytest-doctestplus/actions + :alt: CI Status Questions, bug reports, and feature requests can be submitted on `github`_. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/licenses/README.rst new/pytest-doctestplus-0.9.0/licenses/README.rst --- old/pytest-doctestplus-0.8.0/licenses/README.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-doctestplus-0.9.0/licenses/README.rst 2021-01-15 02:19:47.000000000 +0100 @@ -0,0 +1,6 @@ +Licenses +======== + +This directory holds license and credit information for works this plugin is derived from or distributes, and/or datasets. + +The license file for this package itself is placed in the root directory of this repository. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/licenses/SYMPY_LICENSE.rst new/pytest-doctestplus-0.9.0/licenses/SYMPY_LICENSE.rst --- old/pytest-doctestplus-0.8.0/licenses/SYMPY_LICENSE.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-doctestplus-0.9.0/licenses/SYMPY_LICENSE.rst 2021-01-15 02:19:47.000000000 +0100 @@ -0,0 +1,28 @@ +Copyright (c) 2006-2014 SymPy Development Team + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + a. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + b. 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. + c. Neither the name of SymPy 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 REGENTS 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. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/pyproject.toml new/pytest-doctestplus-0.9.0/pyproject.toml --- old/pytest-doctestplus-0.8.0/pyproject.toml 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-doctestplus-0.9.0/pyproject.toml 2021-01-15 02:19:47.000000000 +0100 @@ -0,0 +1,5 @@ +[build-system] +requires = ["setuptools>=30.3.0", + "setuptools_scm", + "wheel"] +build-backend = 'setuptools.build_meta' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/pytest_doctestplus/__init__.py new/pytest-doctestplus-0.9.0/pytest_doctestplus/__init__.py --- old/pytest-doctestplus-0.8.0/pytest_doctestplus/__init__.py 2020-07-31 22:55:19.000000000 +0200 +++ new/pytest-doctestplus-0.9.0/pytest_doctestplus/__init__.py 2021-01-15 02:19:47.000000000 +0100 @@ -1,6 +1,3 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst -""" -This package contains pytest plugins that are used by the astropy test suite. -""" -__version__ = '0.8.0.dev0' +from .version import version as __version__ # noqa diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/pytest_doctestplus/output_checker.py new/pytest-doctestplus-0.9.0/pytest_doctestplus/output_checker.py --- old/pytest-doctestplus-0.8.0/pytest_doctestplus/output_checker.py 2020-07-31 22:55:19.000000000 +0200 +++ new/pytest-doctestplus-0.9.0/pytest_doctestplus/output_checker.py 2021-01-15 02:19:47.000000000 +0100 @@ -20,6 +20,7 @@ IGNORE_OUTPUT = doctest.register_optionflag('IGNORE_OUTPUT') IGNORE_OUTPUT_3 = doctest.register_optionflag('IGNORE_OUTPUT_3') IGNORE_WARNINGS = doctest.register_optionflag('IGNORE_WARNINGS') +SHOW_WARNINGS = doctest.register_optionflag('SHOW_WARNINGS') # These might appear in some doctests and are used in the default pytest # doctest plugin. This plugin doesn't actually implement these flags but this diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/pytest_doctestplus/plugin.py new/pytest-doctestplus-0.9.0/pytest_doctestplus/plugin.py --- old/pytest-doctestplus-0.8.0/pytest_doctestplus/plugin.py 2020-07-31 22:55:19.000000000 +0200 +++ new/pytest-doctestplus-0.9.0/pytest_doctestplus/plugin.py 2021-01-15 02:19:47.000000000 +0100 @@ -9,21 +9,20 @@ import re import sys import warnings - -from packaging.version import Version +from pathlib import Path +from textwrap import indent import pytest +from packaging.version import Version from pytest_doctestplus.utils import ModuleChecker -from .output_checker import FIX, IGNORE_WARNINGS, OutputChecker, REMOTE_DATA -try: - from textwrap import indent -except ImportError: # PY2 - def indent(text, prefix): - return '\n'.join([prefix + line for line in text.splitlines()]) +from .output_checker import (FIX, IGNORE_WARNINGS, REMOTE_DATA, SHOW_WARNINGS, + OutputChecker) -PYTEST_GT_5 = Version(pytest.__version__) > Version('5.9.9') +_pytest_version = Version(pytest.__version__) +PYTEST_GT_5 = _pytest_version > Version('5.9.9') +PYTEST_GE_6_3 = _pytest_version.is_devrelease or _pytest_version >= Version('6.3') comment_characters = { '.txt': '#', @@ -32,12 +31,12 @@ } -# For the IGNORE_WARNINGS option, we create a context manager that doesn't -# require us to add any imports to the example list and contains everything -# that is needed to silence warnings. +# For the IGNORE_WARNINGS and SHOW_WARNINGS option, we create a context manager +# that doesn't require us to add any imports to the example list and contains +# everything that is needed to silence or print warnings. IGNORE_WARNINGS_CONTEXT = """ -class _doctestplus_ignore_all_warnings(object): +class _doctestplus_ignore_all_warnings: def __init__(self): import warnings @@ -54,6 +53,26 @@ """.lstrip() +SHOW_WARNINGS_CONTEXT = """ +class _doctestplus_show_all_warnings: + + def __init__(self): + import warnings + self._cw = warnings.catch_warnings(record=True) + + def __enter__(self, *args, **kwargs): + self.result = self._cw.__enter__(*args, **kwargs) + import warnings + warnings.simplefilter('always') + return self.result + + def __exit__(self, *args, **kwargs): + self._cw.__exit__(*args, **kwargs) + for warn in self.result: + print(f'{warn._category_name}: {warn.message}') +""".lstrip() + + # these pytest hooks allow us to mark tests and run the marked tests with # specific command line options. def pytest_addoption(parser): @@ -173,7 +192,10 @@ if self.fspath.basename == "setup.py": return elif self.fspath.basename == "conftest.py": - if PYTEST_GT_5: + if PYTEST_GE_6_3: + module = self.config.pluginmanager._importconftest( + Path(self.fspath), self.config.getoption("importmode")) + elif PYTEST_GT_5: module = self.config.pluginmanager._importconftest( self.fspath, self.config.getoption("importmode")) else: @@ -200,6 +222,7 @@ if config.getoption('remote_data', 'none') != 'any': ignore_warnings_context_needed = False + show_warnings_context_needed = False for example in test.examples: @@ -210,13 +233,24 @@ + indent(example.source, ' ')) ignore_warnings_context_needed = True + # Same for SHOW_WARNINGS + if example.options.get(SHOW_WARNINGS, False): + example.source = ("with _doctestplus_show_all_warnings():\n" + + indent(example.source, ' ')) + show_warnings_context_needed = True + if example.options.get(REMOTE_DATA): example.options[doctest.SKIP] = True # We insert the definition of the context manager to ignore # warnings at the start of the file if needed. if ignore_warnings_context_needed: - test.examples.insert(0, doctest.Example(source=IGNORE_WARNINGS_CONTEXT, want='')) + test.examples.insert(0, doctest.Example( + source=IGNORE_WARNINGS_CONTEXT, want='')) + + if show_warnings_context_needed: + test.examples.insert(0, doctest.Example( + source=SHOW_WARNINGS_CONTEXT, want='')) try: yield doctest_plugin.DoctestItem.from_parent( @@ -289,6 +323,7 @@ comment_char = comment_characters[ext] ignore_warnings_context_needed = False + show_warnings_context_needed = False for entry in result: @@ -344,6 +379,12 @@ + indent(entry.source, ' ')) ignore_warnings_context_needed = True + # Same to show warnings + if entry.options.get(SHOW_WARNINGS, False): + entry.source = ("with _doctestplus_show_all_warnings():\n" + + indent(entry.source, ' ')) + show_warnings_context_needed = True + has_required_modules = DocTestFinderPlus.check_required_modules(required) if skip_all or skip_next or not has_required_modules: entry.options[doctest.SKIP] = True @@ -356,6 +397,9 @@ if ignore_warnings_context_needed: result.insert(0, doctest.Example(source=IGNORE_WARNINGS_CONTEXT, want='')) + if show_warnings_context_needed: + result.insert(0, doctest.Example(source=SHOW_WARNINGS_CONTEXT, want='')) + return result config.pluginmanager.register( @@ -391,7 +435,11 @@ Skip paths that match any of the doctest_norecursedirs patterns or if doctest_only is True then skip all regular test files (eg test_*.py). """ - collect_ignore = config._getconftest_pathlist("collect_ignore", path=path.dirpath()) + if PYTEST_GE_6_3: + dirpath = Path(path).parent + else: + dirpath = path.dirpath() + collect_ignore = config._getconftest_pathlist("collect_ignore", path=dirpath) # The collect_ignore conftest.py variable should cause all test # runners to ignore this file and all subfiles and subdirectories diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/pytest_doctestplus/sphinx/doctestplus.py new/pytest-doctestplus-0.9.0/pytest_doctestplus/sphinx/doctestplus.py --- old/pytest-doctestplus-0.8.0/pytest_doctestplus/sphinx/doctestplus.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-doctestplus-0.9.0/pytest_doctestplus/sphinx/doctestplus.py 2021-01-15 02:19:47.000000000 +0100 @@ -0,0 +1,56 @@ +# Licensed under a 3-clause BSD style license - see LICENSE.rst +""" +This is a set of three directives that allow us to insert metadata +about doctests into the .rst files so the testing framework knows +which tests to skip. + +This is quite different from the doctest extension in Sphinx itself, +which actually does something. For astropy, all of the testing is +centrally managed from py.test and Sphinx is not used for running +tests. +""" +import re +from docutils.nodes import literal_block +from docutils.parsers.rst import Directive + + +class DoctestSkipDirective(Directive): + has_content = True + + def run(self): + # Check if there is any valid argument, and skip it. Currently only + # 'win32' is supported in astropy.tests.pytest_plugins. + if re.match('win32', self.content[0]): + self.content = self.content[2:] + code = '\n'.join(self.content) + return [literal_block(code, code)] + + +class DoctestOmitDirective(Directive): + has_content = True + + def run(self): + # Simply do not add any content when this directive is encountered + return [] + + +class DoctestRequiresDirective(DoctestSkipDirective): + # This is silly, but we really support an unbounded number of + # optional arguments + optional_arguments = 64 + + +def setup(app): + + app.add_directive('doctest-requires', DoctestRequiresDirective) + app.add_directive('doctest-skip', DoctestSkipDirective) + app.add_directive('doctest-skip-all', DoctestSkipDirective) + app.add_directive('doctest', DoctestSkipDirective, override=True) + # Code blocks that use this directive will not appear in the generated + # documentation. This is intended to hide boilerplate code that is only + # useful for testing documentation using doctest, but does not actually + # belong in the documentation itself. + app.add_directive('testsetup', DoctestOmitDirective, override=True) + + return {'parallel_read_safe': True, + 'parallel_write_safe': True} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/pytest_doctestplus/utils.py new/pytest-doctestplus-0.9.0/pytest_doctestplus/utils.py --- old/pytest-doctestplus-0.8.0/pytest_doctestplus/utils.py 2020-07-31 22:55:19.000000000 +0200 +++ new/pytest-doctestplus-0.9.0/pytest_doctestplus/utils.py 2021-01-15 02:19:47.000000000 +0100 @@ -1,82 +1,22 @@ import importlib.util -import json -import logging -import operator -import re -import subprocess -import sys -from packaging.version import Version import pkg_resources -logger = logging.getLogger(__name__) - class ModuleChecker: - def __init__(self): - self._find_module = importlib.util.find_spec - self._find_distribution = pkg_resources.require - self.packages = {} - - def get_packages(self): - packages = subprocess.check_output( - [sys.executable, '-m', 'pip', 'list', '--format', 'json'] - ).decode() - packages = {item['name'].lower(): item['version'] - for item in json.loads(packages)} - return packages - - def compare_versions(self, v1, v2, op): - op_map = { - '<': operator.lt, - '<=': operator.le, - '>': operator.gt, - '>=': operator.ge, - '==': operator.eq, - } - if op not in op_map: - return False - op = op_map[op] - return op(Version(v1), Version(v2)) - - def _check_distribution(self, module): - """ - Python 2 (and <3.4) compatible version of pkg_resources.require. - But unlike pkg_resources.require it just checks whether package is - installed and has required version. - """ - match = re.match(r'([A-Za-z0-9-_]+)([^A-Za-z0-9-_]+)([\d.]+$)', module) - if not match: - return False - package, cmp, version = match.groups() - package = package.lower() - - if package in self.packages: - installed_version = self.packages[package] - if self.compare_versions(installed_version, version, cmp): - return True - else: - logger.warning( - "{} {} is installed. Version {}{} is required".format( - package, installed_version, cmp, version - ) - ) - return False - logger.warning("The '{}' distribution was not found and is required by the application".format(package)) - return False def find_module(self, module): """Search for modules specification.""" try: - return self._find_module(module) + return importlib.util.find_spec(module) except ImportError: return None def find_distribution(self, dist): """Search for distribution with specified version (eg 'numpy>=1.15').""" try: - return self._find_distribution(dist) - except Exception as e: + return pkg_resources.require(dist) + except Exception: return None def check(self, module): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/pytest_doctestplus/version.py new/pytest-doctestplus-0.9.0/pytest_doctestplus/version.py --- old/pytest-doctestplus-0.8.0/pytest_doctestplus/version.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-doctestplus-0.9.0/pytest_doctestplus/version.py 2021-01-15 02:19:55.000000000 +0100 @@ -0,0 +1,5 @@ +# coding: utf-8 +# file generated by setuptools_scm +# don't change, don't track in version control +version = '0.9.0' +version_tuple = (0, 9, 0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/pytest_doctestplus.egg-info/PKG-INFO new/pytest-doctestplus-0.9.0/pytest_doctestplus.egg-info/PKG-INFO --- old/pytest-doctestplus-0.8.0/pytest_doctestplus.egg-info/PKG-INFO 2020-07-31 23:04:35.000000000 +0200 +++ new/pytest-doctestplus-0.9.0/pytest_doctestplus.egg-info/PKG-INFO 2021-01-15 02:19:55.000000000 +0100 @@ -1,8 +1,8 @@ Metadata-Version: 2.1 Name: pytest-doctestplus -Version: 0.8.0 +Version: 0.9.0 Summary: Pytest plugin with advanced doctest features. -Home-page: https://astropy.org +Home-page: https://github.com/astropy/pytest-doctestplus Author: The Astropy Developers Author-email: astropy.t...@gmail.com License: BSD @@ -16,7 +16,7 @@ been moved to a separate package in order to be of more general use. .. _pytest: https://pytest.org/en/latest/ - .. _astropy: https://astropy.org/en/latest/ + .. _astropy: https://astropy.org/ .. _reStructuredText: https://en.wikipedia.org/wiki/ReStructuredText @@ -57,7 +57,7 @@ $ git clone https://github.com/astropy/pytest-doctestplus $ cd pytest-doctestplus - $ python ./setup.py install + $ pip install . In either case, the plugin will automatically be registered for use with ``pytest``. @@ -155,6 +155,23 @@ >>> np.mean([]) # doctest: +IGNORE_WARNINGS np.nan + Showing warnings + ~~~~~~~~~~~~~~~~ + + If code in a doctest emits a warning and you want to make sure that warning is + shown, you can make use of the ``SHOW_WARNINGS`` flag. This is useful when + warnings are turned into errors by pytest, and also because by default warnings + are printed to stderr. This is the opposite from ``IGNORE_WARNINGS`` so + obviously the two flags should not be used together. For example: + + .. code-block:: python + + >>> import numpy as np + >>> np.mean([]) # doctest: +SHOW_WARNINGS + RuntimeWarning: Mean of empty slice. + RuntimeWarning: invalid value encountered in double_scalars + np.nan + Skipping Tests ~~~~~~~~~~~~~~ @@ -269,12 +286,23 @@ .. _pytest-remotedata: https://github.com/astropy/pytest-remotedata __ pytest-remotedata_ + Sphinx Compatibility + ~~~~~~~~~~~~~~~~~~~~ + + To use the additional directives when building your documentation with sphinx + you may want to enable the sphinx extension which registers these directives + with sphinx. Doing so ensures that sphinx correctly ignores these directives, + running the doctests with sphinx is not supported. To do this, add + ``'pytest_doctestplus.sphinx.doctestplus'`` to your ``extensions`` list in your + ``conf.py`` file. + + Development Status ------------------ - .. image:: https://travis-ci.org/astropy/pytest-doctestplus.svg - :target: https://travis-ci.org/astropy/pytest-doctestplus - :alt: Travis CI Status + .. image:: https://github.com/astropy/pytest-doctestplus/workflows/Run%20unit%20tests/badge.svg + :target: https://github.com/astropy/pytest-doctestplus/actions + :alt: CI Status Questions, bug reports, and feature requests can be submitted on `github`_. @@ -294,6 +322,7 @@ Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/pytest_doctestplus.egg-info/SOURCES.txt new/pytest-doctestplus-0.9.0/pytest_doctestplus.egg-info/SOURCES.txt --- old/pytest-doctestplus-0.8.0/pytest_doctestplus.egg-info/SOURCES.txt 2020-07-31 23:04:35.000000000 +0200 +++ new/pytest-doctestplus-0.9.0/pytest_doctestplus.egg-info/SOURCES.txt 2021-01-15 02:19:55.000000000 +0100 @@ -1,13 +1,21 @@ +.gitignore CHANGES.rst LICENSE.rst MANIFEST.in README.rst +pyproject.toml setup.cfg setup.py +tox.ini +.github/workflows/publish.yml +.github/workflows/python-tests.yml +licenses/README.rst +licenses/SYMPY_LICENSE.rst pytest_doctestplus/__init__.py pytest_doctestplus/output_checker.py pytest_doctestplus/plugin.py pytest_doctestplus/utils.py +pytest_doctestplus/version.py pytest_doctestplus.egg-info/PKG-INFO pytest_doctestplus.egg-info/SOURCES.txt pytest_doctestplus.egg-info/dependency_links.txt @@ -15,6 +23,8 @@ pytest_doctestplus.egg-info/not-zip-safe pytest_doctestplus.egg-info/requires.txt pytest_doctestplus.egg-info/top_level.txt +pytest_doctestplus/sphinx/__init__.py +pytest_doctestplus/sphinx/doctestplus.py tests/conftest.py tests/test_doctestplus.py tests/test_utils.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/pytest_doctestplus.egg-info/requires.txt new/pytest-doctestplus-0.9.0/pytest_doctestplus.egg-info/requires.txt --- old/pytest-doctestplus-0.8.0/pytest_doctestplus.egg-info/requires.txt 2020-07-31 23:04:35.000000000 +0200 +++ new/pytest-doctestplus-0.9.0/pytest_doctestplus.egg-info/requires.txt 2021-01-15 02:19:55.000000000 +0100 @@ -1,2 +1,2 @@ -pytest>=4.0 -pip +pytest>=4.6 +setuptools>=30.3.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/setup.cfg new/pytest-doctestplus-0.9.0/setup.cfg --- old/pytest-doctestplus-0.8.0/setup.cfg 2020-07-31 23:04:35.412392400 +0200 +++ new/pytest-doctestplus-0.9.0/setup.cfg 2021-01-15 02:19:55.924952300 +0100 @@ -1,5 +1,49 @@ +[metadata] +name = pytest-doctestplus +url = https://github.com/astropy/pytest-doctestplus +author = The Astropy Developers +author_email = astropy.t...@gmail.com +classifiers = + Development Status :: 3 - Alpha + Framework :: Pytest + Intended Audience :: Developers + License :: OSI Approved :: BSD License + Operating System :: OS Independent + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: Implementation :: CPython + Topic :: Software Development :: Testing + Topic :: Utilities +license = BSD +description = Pytest plugin with advanced doctest features. +long_description = file: README.rst +long_description_content_type = text/x-rst +keywords = doctest, rst, pytest, py.test + +[options] +zip_safe = False +packages = find: +python_requires = >=3.6 +setup_requires = + setuptools_scm +install_requires = + pytest>=4.6 + setuptools>=30.3.0 + +[options.entry_points] +pytest11 = + pytest_doctestplus = pytest_doctestplus.plugin + +[options.packages.find] +exclude = + tests + [tool:pytest] -minversion = 3.0 +minversion = 4.6 testpaths = tests pytest_doctestplus xfail_strict = true filterwarnings = diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/setup.py new/pytest-doctestplus-0.9.0/setup.py --- old/pytest-doctestplus-0.8.0/setup.py 2020-07-31 23:01:05.000000000 +0200 +++ new/pytest-doctestplus-0.9.0/setup.py 2021-01-15 02:19:47.000000000 +0100 @@ -1,49 +1,6 @@ #!/usr/bin/env python -# Licensed under a 3-clause BSD style license - see LICENSE.rst -# -*- encoding: utf-8 -*- -from setuptools import setup, find_packages +import os +from setuptools import setup - -def readme(): - with open('README.rst') as ff: - return ff.read() - - -setup( - name='pytest-doctestplus', - version='0.8.0', - license='BSD', - description='Pytest plugin with advanced doctest features.', - long_description=readme(), - long_description_content_type='text/x-rst', - author='The Astropy Developers', - author_email='astropy.t...@gmail.com', - url='https://astropy.org', - packages=find_packages(exclude=['tests']), - include_package_data=True, - zip_safe=False, - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Framework :: Pytest', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: BSD License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: Implementation :: CPython', - 'Topic :: Software Development :: Testing', - 'Topic :: Utilities', - ], - keywords=['doctest', 'rst', 'pytest', 'py.test'], - install_requires=['pytest>=4.0', 'pip'], - python_requires='>=3.6', - entry_points={ - 'pytest11': [ - 'pytest_doctestplus = pytest_doctestplus.plugin', - ], - }, -) +setup(use_scm_version={'write_to': os.path.join('pytest_doctestplus', 'version.py')}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/tests/test_doctestplus.py new/pytest-doctestplus-0.9.0/tests/test_doctestplus.py --- old/pytest-doctestplus-0.8.0/tests/test_doctestplus.py 2020-07-31 22:55:19.000000000 +0200 +++ new/pytest-doctestplus-0.9.0/tests/test_doctestplus.py 2021-01-15 02:19:47.000000000 +0100 @@ -454,6 +454,72 @@ reprec.assertoutcome(failed=0, passed=1) +def test_show_warnings_module(testdir): + + p = testdir.makepyfile( + """ + def myfunc(): + ''' + >>> import warnings + >>> warnings.warn('A warning occurred', UserWarning) # doctest: +SHOW_WARNINGS + UserWarning: A warning occurred + ''' + pass + """) + reprec = testdir.inline_run(p, "--doctest-plus", "-W error") + reprec.assertoutcome(failed=0, passed=1) + + # Make sure it fails if warning message is missing + p = testdir.makepyfile( + """ + def myfunc(): + ''' + >>> import warnings + >>> warnings.warn('A warning occurred', UserWarning) # doctest: +SHOW_WARNINGS + ''' + pass + """) + reprec = testdir.inline_run(p, "--doctest-plus", "-W error") + reprec.assertoutcome(failed=1, passed=0) + + +def test_show_warnings_rst(testdir): + + p = testdir.makefile(".rst", + """ + :: + >>> import warnings + >>> warnings.warn('A warning occurred', UserWarning) # doctest: +SHOW_WARNINGS + UserWarning: A warning occurred + """) + reprec = testdir.inline_run(p, "--doctest-plus", "--doctest-rst", + "--text-file-format=rst", "-W error") + reprec.assertoutcome(failed=0, passed=1) + + # Make sure it fails if warning message is missing + p = testdir.makefile(".rst", + """ + :: + >>> import warnings + >>> warnings.warn('A warning occurred', UserWarning) # doctest: +SHOW_WARNINGS + """) + reprec = testdir.inline_run(p, "--doctest-plus", "--doctest-rst", + "--text-file-format=rst", "-W error") + reprec.assertoutcome(failed=1, passed=0) + + # Make sure it fails if warning message is missing + p = testdir.makefile(".rst", + """ + :: + >>> import warnings + >>> warnings.warn('A warning occurred', UserWarning) # doctest: +SHOW_WARNINGS + Warning: Another warning occurred + """) + reprec = testdir.inline_run(p, "--doctest-plus", "--doctest-rst", + "--text-file-format=rst", "-W error") + reprec.assertoutcome(failed=1, passed=0) + + def test_doctest_glob(testdir): testdir.makefile( '.rst', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/tests/test_utils.py new/pytest-doctestplus-0.9.0/tests/test_utils.py --- old/pytest-doctestplus-0.8.0/tests/test_utils.py 2020-07-31 22:55:19.000000000 +0200 +++ new/pytest-doctestplus-0.9.0/tests/test_utils.py 2021-01-15 02:19:47.000000000 +0100 @@ -11,15 +11,3 @@ c = ModuleChecker() assert c.check('pytest>1.0') assert not c.check('foobar>1.0') - - def test_check_distribution(self): - c = ModuleChecker() - # in python3.4+ packages attribute will not be populated - # because it calls 'pip freeze' which is slow - if not c.packages: - c.packages = c.get_packages() - # after this we will be able to test _check_distribution even in - # python3.4+ environment - assert c._check_distribution('pytest>1.0') - assert not c._check_distribution('pytest<1.0') - assert not c._check_distribution('foobar>1.0') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pytest-doctestplus-0.8.0/tox.ini new/pytest-doctestplus-0.9.0/tox.ini --- old/pytest-doctestplus-0.8.0/tox.ini 1970-01-01 01:00:00.000000000 +0100 +++ new/pytest-doctestplus-0.9.0/tox.ini 2021-01-15 02:19:47.000000000 +0100 @@ -0,0 +1,35 @@ +[tox] +envlist = + py{36,37,38,39}-test + codestyle +requires = + setuptools >= 30.3.0 + pip >= 19.3.1 +isolated_build = true + +[testenv] +changedir = .tmp/{envname} +description = run tests +deps = + pytest46: pytest==4.6.* + pytest50: pytest==5.0.* + pytest51: pytest==5.1.* + pytest52: pytest==5.2.* + pytest53: pytest==5.3.* + pytest60: pytest==6.0.* + pytest61: pytest==6.1.* + pytestdev: git+https://github.com/pytest-dev/pytest#egg=pytest + +commands = + pip freeze + pytest {toxinidir}/tests {posargs} + pytest {toxinidir}/tests --doctest-plus {posargs} + pytest {toxinidir}/tests --doctest-plus --doctest-rst {posargs} + pytest {toxinidir}/tests --doctest-plus --doctest-rst --text-file-format=tex {posargs} + +[testenv:codestyle] +changedir = +skip_install = true +description = check code style, e.g. with flake8 +deps = flake8 +commands = flake8 pytest_doctestplus --count