././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1578582654.6793394 pytest-filter-subpackage-0.1.1/0000755000077000000240000000000000000000000016346 5ustar00tomstaff00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1577619324.0 pytest-filter-subpackage-0.1.1/.gitignore0000644000077000000240000000117200000000000020337 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 # Env .venv venv .env # Mac OSX .DS_Store # PyCharm .idea pytest_filter_subpackage/version.py ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1578582632.0 pytest-filter-subpackage-0.1.1/CHANGES.rst0000644000077000000240000000026000000000000020146 0ustar00tomstaff000000000000000.1.1 (2020-01-09) ================== - Fixed bug that caused e.g. ``-P sub`` to not match ``package.sub.other``. [#1] 0.1 (2020-01-09) ================ - Initial version. ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1577438458.0 pytest-filter-subpackage-0.1.1/LICENSE.rst0000644000077000000240000000272300000000000020166 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=1577622410.0 pytest-filter-subpackage-0.1.1/MANIFEST.in0000644000077000000240000000023200000000000020101 0ustar00tomstaff00000000000000include LICENSE.rst include README.rst include CHANGES.rst include pyproject.toml include setup.cfg recursive-include tests * global-exclude *.pyc *.o ././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1578582654.6799643 pytest-filter-subpackage-0.1.1/PKG-INFO0000644000077000000240000000535600000000000017454 0ustar00tomstaff00000000000000Metadata-Version: 2.1 Name: pytest-filter-subpackage Version: 0.1.1 Summary: Pytest plugin for filtering based on sub-packages Home-page: https://astropy.org Author: The Astropy Developers Author-email: astropy.team@gmail.com License: BSD Description: ======================== pytest-filter-subpackage ======================== .. image:: https://dev.azure.com/astropy-project/pytest-filter-subpackage/_apis/build/status/astropy.pytest-filter-subpackage?branchName=master :target: https://dev.azure.com/astropy-project/pytest-filter-subpackage/_build/latest?definitionId=5&branchName=master This package contains a simple plugin for the `pytest`_ framework that provides a shortcut to testing all code and documentation for a given sub-package. .. _pytest: https://pytest.org/en/latest/ Installation ------------ The ``pytest-filter-subpackage`` plugin can be installed using ``pip``:: $ pip install pytest-filter-subpackage It is also possible to install the latest development version from the source repository:: $ git clone https://github.com/astropy/pytest-filter-subpackage $ cd pytest-filter-subpackage $ pip install . In either case, the plugin will automatically be registered for use with ``pytest``. Usage ----- This plugin provides a ``-P`` option which takes a comma-separated list of sub-package names (without the top-level package name):: pytest -P wcs,io.fits which is equivalent to:: pytest **/wcs **/io/fits When used in conjunction with `pytest-doctestplus `_ this will result in both the narrative documentation and code being tested for a given sub-package. License ------- This plugin is licensed under a 3-clause BSD style license - see the ``LICENSE.rst`` file. Keywords: pytest,py.test Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Framework :: Pytest Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Topic :: Software Development :: Testing Classifier: Topic :: Utilities Requires-Python: >=3.6 Provides-Extra: test ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1577623294.0 pytest-filter-subpackage-0.1.1/README.rst0000644000077000000240000000276300000000000020045 0ustar00tomstaff00000000000000======================== pytest-filter-subpackage ======================== .. image:: https://dev.azure.com/astropy-project/pytest-filter-subpackage/_apis/build/status/astropy.pytest-filter-subpackage?branchName=master :target: https://dev.azure.com/astropy-project/pytest-filter-subpackage/_build/latest?definitionId=5&branchName=master This package contains a simple plugin for the `pytest`_ framework that provides a shortcut to testing all code and documentation for a given sub-package. .. _pytest: https://pytest.org/en/latest/ Installation ------------ The ``pytest-filter-subpackage`` plugin can be installed using ``pip``:: $ pip install pytest-filter-subpackage It is also possible to install the latest development version from the source repository:: $ git clone https://github.com/astropy/pytest-filter-subpackage $ cd pytest-filter-subpackage $ pip install . In either case, the plugin will automatically be registered for use with ``pytest``. Usage ----- This plugin provides a ``-P`` option which takes a comma-separated list of sub-package names (without the top-level package name):: pytest -P wcs,io.fits which is equivalent to:: pytest **/wcs **/io/fits When used in conjunction with `pytest-doctestplus `_ this will result in both the narrative documentation and code being tested for a given sub-package. License ------- This plugin is licensed under a 3-clause BSD style license - see the ``LICENSE.rst`` file. ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1578580798.0 pytest-filter-subpackage-0.1.1/azure-pipelines.yml0000644000077000000240000000077500000000000022216 0ustar00tomstaff00000000000000resources: repositories: - repository: OpenAstronomy type: github endpoint: astropy name: OpenAstronomy/azure-pipelines-templates ref: master jobs: - template: run-tox-env.yml@OpenAstronomy parameters: envs: # Code style - linux: codestyle # Standard tests - linux: py36-test - linux: py37-test - linux: py38-test - macos: py36-test - macos: py37-test - macos: py38-test - windows: py36-test - windows: py37-test - windows: py38-test ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1577619690.0 pytest-filter-subpackage-0.1.1/pyproject.toml0000644000077000000240000000020400000000000021256 0ustar00tomstaff00000000000000[build-system] requires = ["setuptools", "setuptools_scm", "wheel"] build-backend = 'setuptools.build_meta' ././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1578582654.6692116 pytest-filter-subpackage-0.1.1/pytest_filter_subpackage/0000755000077000000240000000000000000000000023430 5ustar00tomstaff00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1577619575.0 pytest-filter-subpackage-0.1.1/pytest_filter_subpackage/__init__.py0000644000077000000240000000016500000000000025543 0ustar00tomstaff00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst from .version import version as __version__ # noqa ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1578581654.0 pytest-filter-subpackage-0.1.1/pytest_filter_subpackage/plugin.py0000644000077000000240000000424700000000000025307 0ustar00tomstaff00000000000000# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This plugin provides support for specifying the -P option to test both code and docs for a specific sub-package. """ import os import pytest def pytest_addoption(parser): parser.addoption("--package", "-P", action="store", help="The name of a specific package to test, e.g. " "'io.fits' or 'utils'. Accepts comma separated " "string to specify multiple packages.") @pytest.hookimpl(tryfirst=True) def pytest_ignore_collect(path, config): # NOTE: it is important that when we don't want to skip a file we return # None and not False - if we return False pytest will not call any other # pytest_ignore_collect function in other plugins, e.g. pytest-doctestplus. # If the --package/-P option wasn't specified, don't do anything if config.getvalue('package') is None: return None # If the path is a directory, never skip - just do the filtering on a file # by file basis. if os.path.isdir(path): return None # Otherwise ignore filename for remainder of checks path = os.path.dirname(path) # Split path into components path = path.split(os.path.sep) # Now cycle through and find the top level of the package - this is the # last one that contains an ``__init__.py`` or ``index.rst`` file. We need # to make sure that at least one of these files was found before escaping. found_prev = False for i in range(len(path), -1, -1): subpath = os.path.sep.join(path[:i]) found = (os.path.exists(os.path.join(subpath, '__init__.py')) or os.path.exists(os.path.join(subpath, 'index.rst'))) if found_prev and not found: break found_prev = found path = os.path.sep.join(path[i+1:]) subpackage = '.'.join(path.split(os.path.sep)) # Find selected sub-packages selected = config.getvalue('package').strip().split(',') # Finally, we check if this is one of the specified ones for subpackage_target in selected: if subpackage.startswith(subpackage_target): return None return True ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1578582654.0 pytest-filter-subpackage-0.1.1/pytest_filter_subpackage/version.py0000644000077000000240000000016400000000000025470 0ustar00tomstaff00000000000000# coding: utf-8 # file generated by setuptools_scm # don't change, don't track in version control version = '0.1.1' ././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1578582654.6747923 pytest-filter-subpackage-0.1.1/pytest_filter_subpackage.egg-info/0000755000077000000240000000000000000000000025122 5ustar00tomstaff00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1578582654.0 pytest-filter-subpackage-0.1.1/pytest_filter_subpackage.egg-info/PKG-INFO0000644000077000000240000000535600000000000026230 0ustar00tomstaff00000000000000Metadata-Version: 2.1 Name: pytest-filter-subpackage Version: 0.1.1 Summary: Pytest plugin for filtering based on sub-packages Home-page: https://astropy.org Author: The Astropy Developers Author-email: astropy.team@gmail.com License: BSD Description: ======================== pytest-filter-subpackage ======================== .. image:: https://dev.azure.com/astropy-project/pytest-filter-subpackage/_apis/build/status/astropy.pytest-filter-subpackage?branchName=master :target: https://dev.azure.com/astropy-project/pytest-filter-subpackage/_build/latest?definitionId=5&branchName=master This package contains a simple plugin for the `pytest`_ framework that provides a shortcut to testing all code and documentation for a given sub-package. .. _pytest: https://pytest.org/en/latest/ Installation ------------ The ``pytest-filter-subpackage`` plugin can be installed using ``pip``:: $ pip install pytest-filter-subpackage It is also possible to install the latest development version from the source repository:: $ git clone https://github.com/astropy/pytest-filter-subpackage $ cd pytest-filter-subpackage $ pip install . In either case, the plugin will automatically be registered for use with ``pytest``. Usage ----- This plugin provides a ``-P`` option which takes a comma-separated list of sub-package names (without the top-level package name):: pytest -P wcs,io.fits which is equivalent to:: pytest **/wcs **/io/fits When used in conjunction with `pytest-doctestplus `_ this will result in both the narrative documentation and code being tested for a given sub-package. License ------- This plugin is licensed under a 3-clause BSD style license - see the ``LICENSE.rst`` file. Keywords: pytest,py.test Platform: UNKNOWN Classifier: Development Status :: 3 - Alpha Classifier: Framework :: Pytest Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Topic :: Software Development :: Testing Classifier: Topic :: Utilities Requires-Python: >=3.6 Provides-Extra: test ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1578582654.0 pytest-filter-subpackage-0.1.1/pytest_filter_subpackage.egg-info/SOURCES.txt0000644000077000000240000000114600000000000027010 0ustar00tomstaff00000000000000.gitignore CHANGES.rst LICENSE.rst MANIFEST.in README.rst azure-pipelines.yml pyproject.toml setup.cfg setup.py tox.ini pytest_filter_subpackage/__init__.py pytest_filter_subpackage/plugin.py pytest_filter_subpackage/version.py pytest_filter_subpackage.egg-info/PKG-INFO pytest_filter_subpackage.egg-info/SOURCES.txt pytest_filter_subpackage.egg-info/dependency_links.txt pytest_filter_subpackage.egg-info/entry_points.txt pytest_filter_subpackage.egg-info/not-zip-safe pytest_filter_subpackage.egg-info/requires.txt pytest_filter_subpackage.egg-info/top_level.txt tests/conftest.py tests/test_filter_subpackage.py././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1578582654.0 pytest-filter-subpackage-0.1.1/pytest_filter_subpackage.egg-info/dependency_links.txt0000644000077000000240000000000100000000000031170 0ustar00tomstaff00000000000000 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1578582654.0 pytest-filter-subpackage-0.1.1/pytest_filter_subpackage.egg-info/entry_points.txt0000644000077000000240000000010700000000000030416 0ustar00tomstaff00000000000000[pytest11] pytest_filter_subpackage = pytest_filter_subpackage.plugin ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1578582654.0 pytest-filter-subpackage-0.1.1/pytest_filter_subpackage.egg-info/not-zip-safe0000644000077000000240000000000100000000000027350 0ustar00tomstaff00000000000000 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1578582654.0 pytest-filter-subpackage-0.1.1/pytest_filter_subpackage.egg-info/requires.txt0000644000077000000240000000007100000000000027520 0ustar00tomstaff00000000000000pytest>=3.0 [test] pytest pytest-doctestplus pytest-cov ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1578582654.0 pytest-filter-subpackage-0.1.1/pytest_filter_subpackage.egg-info/top_level.txt0000644000077000000240000000003100000000000027646 0ustar00tomstaff00000000000000pytest_filter_subpackage ././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1578582654.6833177 pytest-filter-subpackage-0.1.1/setup.cfg0000644000077000000240000000234200000000000020170 0ustar00tomstaff00000000000000[metadata] name = pytest-filter-subpackage url = https://astropy.org author = The Astropy Developers author_email = astropy.team@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.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Topic :: Software Development :: Testing Topic :: Utilities license = BSD description = Pytest plugin for filtering based on sub-packages long_description = file: README.rst keywords = pytest, py.test [options] zip_safe = False packages = find: python_requires = >=3.6 install_requires = pytest>=3.0 [options.entry_points] pytest11 = pytest_filter_subpackage = pytest_filter_subpackage.plugin [options.extras_require] test = pytest pytest-doctestplus pytest-cov [tool:pytest] minversion = 3.0 testpaths = tests pytest_filter_subpackage xfail_strict = true filterwarnings = error ignore:file format.*:UserWarning ignore:.*non-empty pattern match.*:FutureWarning [bdist_wheel] universal = 1 [egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1577441115.0 pytest-filter-subpackage-0.1.1/setup.py0000755000077000000240000000066200000000000020067 0ustar00tomstaff00000000000000#!/usr/bin/env python import os import sys from distutils.version import LooseVersion try: import setuptools assert LooseVersion(setuptools.__version__) >= LooseVersion('30.3') except (ImportError, AssertionError): sys.stderr.write("ERROR: setuptools 30.3 or later is required\n") sys.exit(1) from setuptools import setup setup(use_scm_version={'write_to': os.path.join('pytest_filter_subpackage', 'version.py')}) ././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1578582654.6770806 pytest-filter-subpackage-0.1.1/tests/0000755000077000000240000000000000000000000017510 5ustar00tomstaff00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1578580798.0 pytest-filter-subpackage-0.1.1/tests/conftest.py0000644000077000000240000000213000000000000021703 0ustar00tomstaff00000000000000import pytest TEST_TEMPLATE = """ def test_{sub}_1(): assert True def test_{sub}_2(): assert '{sub}' == 'a' """ DOCS_TEMPLATE = """ Documentation for {sub} ======================= :: >>> a = 1 >>> b = 2 >>> a + b 3 """ @pytest.fixture def testpackage(testdir): # Fixture to make a test package with a docs and code folder pkg = testdir.mkdir('testpackage') pkg.join('__init__.py').write('') for sub in ('a', 'b', 'c'): pkg.mkdir(sub).join('__init__.py').write('') pkg.join(sub).mkdir('tests').join('__init__.py').write('') pkg.join(sub).join('tests').join(f'test_{sub}.py') \ .write(TEST_TEMPLATE.format(sub=sub)) pkg.join('c').mkdir('d').join('__init__.py').write('') pkg.join('c').join('d').mkdir('tests').join('__init__.py').write('') pkg.join('c').join('d').join('tests').join('test_d.py') \ .write(TEST_TEMPLATE.format(sub='d')) docs = testdir.mkdir('docs') docs.join('index.rst').write('') for sub in ('a', 'c'): docs.mkdir(sub).join('index.rst').write(DOCS_TEMPLATE.format(sub=sub)) ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1578580878.0 pytest-filter-subpackage-0.1.1/tests/test_filter_subpackage.py0000644000077000000240000000320400000000000024572 0ustar00tomstaff00000000000000pytest_plugins = ['pytester'] def test_default(testdir, testpackage): # Make sure all code tests are picked up by default reprec = testdir.inline_run() reprec.assertoutcome(passed=5, failed=3) def test_with_rst(testdir, testpackage): # Make sure all rst tests are also picked up when using pytest-doctestplus testdir.makeini(""" [pytest] doctest_plus = enabled """) reprec = testdir.inline_run('--doctest-rst') reprec.assertoutcome(passed=8, failed=3) def test_flag_single_subpackage(testdir, testpackage): # Test -P with a single sub-package reprec = testdir.inline_run('-P a') reprec.assertoutcome(passed=2, failed=0) def test_flag_single_subpackage_with_rst(testdir, testpackage): # Test -P with a single sub-package including rst files testdir.makeini(""" [pytest] doctest_plus = enabled """) reprec = testdir.inline_run('-P a', '--doctest-rst') reprec.assertoutcome(passed=3, failed=0) def test_flag_multiple_subpackage(testdir, testpackage): # Test -P with several sub-packages reprec = testdir.inline_run('-P a,b') reprec.assertoutcome(passed=3, failed=1) def test_flag_multiple_subpackage_with_rst(testdir, testpackage): # Test -P with several sub-packages including rst files testdir.makeini(""" [pytest] doctest_plus = enabled """) reprec = testdir.inline_run('-P a,b', '--doctest-rst') reprec.assertoutcome(passed=4, failed=1) def test_flag_single_subpackage_partial(testdir, testpackage): # Check that -P c will collect tests in c.d reprec = testdir.inline_run('-P c') reprec.assertoutcome(passed=2, failed=2) ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1578580798.0 pytest-filter-subpackage-0.1.1/tox.ini0000644000077000000240000000071400000000000017663 0ustar00tomstaff00000000000000[tox] envlist = py{36,37,38}-test codestyle requires = setuptools >= 30.3.0 pip >= 19.3.1 isolated_build = true [testenv] changedir = test: .tmp/{envname} description = test: run tests with pytest extras = test: test commands = pip freeze test: pytest {toxinidir}/tests {posargs} [testenv:codestyle] skip_install = true description = check code style deps = flake8 commands = flake8 pytest_filter_subpackage tests --count