././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1639073460.1176386 pytest-doctestplus-0.11.2/0000755000175100001710000000000000000000000016272 5ustar00runnerdocker00000000000000././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1639073460.1096385 pytest-doctestplus-0.11.2/.github/0000755000175100001710000000000000000000000017632 5ustar00runnerdocker00000000000000././@PaxHeader0000000000000000000000000000003400000000000011452 xustar000000000000000028 mtime=1639073460.1136386 pytest-doctestplus-0.11.2/.github/workflows/0000755000175100001710000000000000000000000021667 5ustar00runnerdocker00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1639073441.0 pytest-doctestplus-0.11.2/.github/workflows/publish.yml0000644000175100001710000000236300000000000024064 0ustar00runnerdocker00000000000000name: Release on: pull_request: push: tags: - '*' jobs: build-n-publish: name: Build and publish Python 🐍 distributions 📦 to PyPI runs-on: ubuntu-latest if: ((github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) || contains(github.event.pull_request.labels.*.name, 'Build wheels')) steps: - uses: actions/checkout@v2 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-remotedata pytest-doctestplus/dist/*.whl testenv/bin/pytest pytest-doctestplus/tests --doctest-plus --doctest-rst - name: Publish distribution 📦 to PyPI if: startsWith(github.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@release/v1 with: user: __token__ password: ${{ secrets.pypi_password }} ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1639073441.0 pytest-doctestplus-0.11.2/.github/workflows/python-tests.yml0000644000175100001710000000362100000000000025075 0ustar00runnerdocker00000000000000name: Run unit tests on: pull_request: push: branches: [ main ] 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.7 toxenv: py37-test-pytest46 - os: windows-latest python-version: 3.7 toxenv: py37-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: ubuntu-latest python-version: 3.9 toxenv: py39-test-pytest62 - os: macos-latest python-version: 3.8 toxenv: py38-test-pytestdev - os: ubuntu-latest python-version: '3.10' toxenv: py310-test-pytest70 toxargs: --pre 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 ${{ matrix.toxargs }} -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 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1639073441.0 pytest-doctestplus-0.11.2/.gitignore0000644000175100001710000000123300000000000020261 0ustar00runnerdocker00000000000000# 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 # VS code .vscode pytest_doctestplus/version.py pip-wheel-metadata/ ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1639073441.0 pytest-doctestplus-0.11.2/CHANGES.rst0000644000175100001710000001012500000000000020073 0ustar00runnerdocker000000000000000.11.2 (2021-12-09) =================== - Fix version check for pytest 7.0.0rc1. [#171] - Recognize text beginning with ``\n3", ) testdir.makefile( '.rst', foo_2=".. >>> 1 + 1\n3", ) testdir.makefile( '.tex', foo_3="% >>> 1 + 1\n3", ) testdir.makefile( '.txt', foo_4="# >>> 1 + 1\n3", ) testdir.inline_run( '--doctest-plus', '--doctest-glob', '*.md', '--doctest-glob', '*.rst', '--doctest-glob', '*.tex', '--doctest-glob', '*.txt' ).assertoutcome(passed=0) def test_text_file_comment_chars(testdir): # override default comment chars testdir.makeini( """ [pytest] text_file_extensions = .rst=# .tex=# """ ) testdir.makefile( '.rst', foo_1="# >>> 1 + 1\n3", ) testdir.makefile( '.tex', foo_2="# >>> 1 + 1\n3", ) testdir.inline_run( '--doctest-plus', '--doctest-glob', '*.rst', '--doctest-glob', '*.tex', '--doctest-glob', '*.txt' ).assertoutcome(passed=0) def test_ignore_option(testdir): testdir.makepyfile(foo=""" def f(): ''' >>> 1+1 2 ''' pass """) testdir.makepyfile(bar=""" def f(): ''' >>> 1+1 2 ''' pass """) testdir.makefile('.rst', foo='>>> 1+1\n2') testdir.inline_run('--doctest-plus').assertoutcome(passed=2) testdir.inline_run('--doctest-plus', '--doctest-rst').assertoutcome(passed=3) testdir.inline_run( '--doctest-plus', '--doctest-rst', '--ignore', '.' ).assertoutcome(passed=0) testdir.inline_run( '--doctest-plus', '--doctest-rst', '--ignore', 'bar.py' ).assertoutcome(passed=2) if LooseVersion('4.3.0') <= LooseVersion(pytest.__version__): def test_ignore_glob_option(testdir): testdir.makepyfile(foo=""" def f(): ''' >>> 1+1 2 ''' pass """) testdir.makepyfile(bar=""" def f(): ''' >>> 1+1 2 ''' pass """) testdir.makefile('.rst', foo='>>> 1+1\n2') testdir.inline_run( '--doctest-plus', '--doctest-rst', '--ignore-glob', 'foo*' ).assertoutcome(passed=1) testdir.inline_run( '--doctest-plus', '--doctest-rst', '--ignore-glob', 'bar*' ).assertoutcome(passed=2) testdir.inline_run( '--doctest-plus', '--doctest-rst', '--ignore-glob', '*.rst' ).assertoutcome(passed=2) def test_doctest_only(testdir, makepyfile, maketestfile, makerstfile): # regular python files with doctests makepyfile(p1='>>> 1 + 1\n2') makepyfile(p2='>>> 1 + 1\n3') # regular test files maketestfile(test_1='foo') maketestfile(test_2='bar') # rst files makerstfile(r1='>>> 1 + 1\n2') makerstfile(r3='>>> 1 + 1\n3') makerstfile(r2='>>> 1 + 2\n3') # regular tests testdir.inline_run().assertoutcome(passed=2) # regular + doctests testdir.inline_run("--doctest-plus").assertoutcome(passed=3, failed=1) # regular + doctests + doctest in rst files testdir.inline_run("--doctest-plus", "--doctest-rst").assertoutcome(passed=5, failed=2) # only doctests in python files, implicit usage of doctest-plus testdir.inline_run("--doctest-only").assertoutcome(passed=1, failed=1) # only doctests in python files testdir.inline_run("--doctest-only", "--doctest-rst").assertoutcome(passed=3, failed=2) def test_doctest_float_replacement(tmpdir): test1 = dedent(""" This will demonstrate a doctest that fails due to a few extra decimal places:: >>> 1.0 / 3.0 0.333333333333333311 """) test2 = dedent(""" This is the same test, but it should pass with use of +FLOAT_CMP:: >>> 1.0 / 3.0 # doctest: +FLOAT_CMP 0.333333333333333311 """) test1_rst = tmpdir.join('test1.rst') test2_rst = tmpdir.join('test2.rst') test1_rst.write(test1) test2_rst.write(test2) with pytest.raises(doctest.DocTestFailure): doctest.testfile(str(test1_rst), module_relative=False, raise_on_error=True, verbose=False, encoding='utf-8') doctest.testfile(str(test2_rst), module_relative=False, raise_on_error=True, verbose=False, encoding='utf-8') def test_doctest_subpackage_requires(testdir, caplog): # Note that each entry below has different whitespace around the = to # make sure that all cases work properly. testdir.makeini( """ [pytest] doctest_subpackage_requires = test/a/* = pytest>1 test/b/*= pytest>1;averyfakepackage>99999.9 test/c/*=anotherfakepackage>=22000.1.2 """ ) test = testdir.mkdir('test') a = test.mkdir('a') b = test.mkdir('b') c = test.mkdir('c') pyfile = dedent(""" def f(): ''' >>> 1 1 ''' pass """) a.join('testcode.py').write(pyfile) b.join('testcode.py').write(pyfile) c.join('testcode.py').write(pyfile) reprec = testdir.inline_run(test, "--doctest-plus") reprec.assertoutcome(passed=1) assert reprec.listoutcomes()[0][0].location[0] == os.path.join('test', 'a', 'testcode.py') assert caplog.text == '' def test_doctest_skip(testdir): testdir.makeini( """ [pytest] doctestplus = enabled """) p = testdir.makefile( '.rst', """ .. doctest-skip:: >>> import asdf >>> asdf.open('file.asdf') # doctest: +IGNORE_WARNINGS """ ) testdir.inline_run(p, '--doctest-plus', '--doctest-rst').assertoutcome(skipped=1) # We repeat all testst including remote data with and without it opted in def test_remote_data_url(testdir): testdir.makeini( """ [pytest] doctestplus = enabled """) p = testdir.makefile( '.rst', """ # This test should be skipped when remote data is not requested. .. doctest-remote-data:: >>> from contextlib import closing >>> from urllib.request import urlopen >>> with closing(urlopen('https://www.astropy.org')) as remote: ... remote.read() # doctest: +IGNORE_OUTPUT """ ) testdir.inline_run(p, '--doctest-plus', '--doctest-rst', '--remote-data').assertoutcome(passed=1) testdir.inline_run(p, '--doctest-plus', '--doctest-rst').assertoutcome(skipped=1) def test_remote_data_float_cmp(testdir): testdir.makeini( """ [pytest] doctestplus = enabled """) p = testdir.makefile( '.rst', """ #This test is skipped when remote data is not requested .. doctest-remote-data:: >>> x = 1/3. >>> x # doctest: +FLOAT_CMP 0.333333 """ ) testdir.inline_run(p, '--doctest-plus', '--doctest-rst', '--remote-data').assertoutcome(passed=1) testdir.inline_run(p, '--doctest-plus', '--doctest-rst').assertoutcome(skipped=1) def test_remote_data_ignore_whitespace(testdir): testdir.makeini( """ [pytest] doctest_optionflags = NORMALIZE_WHITESPACE doctestplus = enabled """) p = testdir.makefile( '.rst', """ #This test should be skipped when remote data is not requested, and should #pass when remote data is requested .. doctest-remote-data:: >>> a = "foo " >>> print(a) foo """ ) testdir.inline_run(p, '--doctest-plus', '--doctest-rst', '--remote-data').assertoutcome(passed=1) testdir.inline_run(p, '--doctest-plus', '--doctest-rst').assertoutcome(skipped=1) def test_remote_data_ellipsis(testdir): testdir.makeini( """ [pytest] doctest_optionflags = ELLIPSIS doctestplus = enabled """) p = testdir.makefile( '.rst', """ # This test should be skipped when remote data is not requested, and should # pass when remote data is requested .. doctest-remote-data:: >>> a = "freedom at last" >>> print(a) freedom ... """ ) testdir.inline_run(p, '--doctest-plus', '--doctest-rst', '--remote-data').assertoutcome(passed=1) testdir.inline_run(p, '--doctest-plus', '--doctest-rst').assertoutcome(skipped=1) def test_remote_data_requires(testdir): testdir.makeini( """ [pytest] doctestplus = enabled """) p = testdir.makefile( '.rst', """ # This test should be skipped when remote data is not requested. # It should also be skipped instead of failing when remote data is requested because # the module required does not exist .. doctest-remote-data:: .. doctest-requires:: does-not-exist >>> 1 + 1 3 """ ) testdir.inline_run(p, '--doctest-plus', '--doctest-rst', '--remote-data').assertoutcome(skipped=1) testdir.inline_run(p, '--doctest-plus', '--doctest-rst').assertoutcome(skipped=1) def test_remote_data_ignore_warnings(testdir): testdir.makeini( """ [pytest] doctestplus = enabled """) p = testdir.makefile( '.rst', """ # This test should be skipped if remote data is not requested. .. doctest-remote-data:: >>> import warnings >>> warnings.warn('A warning occurred', UserWarning) # doctest: +IGNORE_WARNINGS """ ) testdir.inline_run(p, '--doctest-plus', '--doctest-rst', '--remote-data').assertoutcome(passed=1) testdir.inline_run(p, '--doctest-plus', '--doctest-rst').assertoutcome(skipped=1) ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1639073441.0 pytest-doctestplus-0.11.2/tests/test_utils.py0000644000175100001710000000052400000000000022206 0ustar00runnerdocker00000000000000from pytest_doctestplus.utils import ModuleChecker class TestModuleChecker: def test_simple(self): c = ModuleChecker() assert c.check('sys') assert not c.check('foobar') def test_with_version(self): c = ModuleChecker() assert c.check('pytest>1.0') assert not c.check('foobar>1.0') ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1639073441.0 pytest-doctestplus-0.11.2/tox.ini0000644000175100001710000000247300000000000017613 0ustar00runnerdocker00000000000000[tox] envlist = py{37,38,39,310}-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.* pytest62: pytest==6.2.* pytest70: pytest==7.0.* pytestdev: git+https://github.com/pytest-dev/pytest#egg=pytest extras = test commands = pip freeze # Ignore directly running tests in ``skip_some_remote_data.rst`` with # ``remote-data`` as there are some artifical failures included in there. pytest {toxinidir}/tests --ignore={toxinidir}/tests/docs/skip_some_remote_data.rst --doctest-plus --doctest-rst --remote-data {posargs} 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} sphinx-build {toxinidir}/tests {toxinidir}/tests/_build/html -W [testenv:codestyle] changedir = skip_install = true description = check code style, e.g. with flake8 deps = flake8 commands = flake8 pytest_doctestplus --count