From 67edfd6249a051f7dd697573c6ad7742162f6655 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Wed, 7 Jun 2023 16:28:43 -0400 Subject: [PATCH 1/4] TST: Add test that should fail in pytest-dev only --- tests/test_doctestplus.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_doctestplus.py b/tests/test_doctestplus.py index d266bc5..a40597d 100644 --- a/tests/test_doctestplus.py +++ b/tests/test_doctestplus.py @@ -1142,3 +1142,26 @@ def foo(): result = testdir.inline_run(build_dir, '--doctest-plus', '--doctest-modules', '--doctest-ufunc') result.assertoutcome(passed=2, failed=0) + + +def test_norecursedirs(pytester): + pytester.makeini( + """ + [pytest] + norecursedirs = \"bad_dir\" + doctestplus = enabled + """ + ) + subdir = pytester.mkdir("bad_dir") + with open(subdir / "test_foobar.py", "w") as fout: + fout.write(""" + def f(): + ''' + >>> x = 1/3. + >>> x + 0.333333 + ''' + fail + """) + reprec = pytester.inline_run(pytester.path, "--doctest-plus") + reprec.assertoutcome(failed=0, passed=0) From 30ae17682d7de91df92e4c30a997616ad7d49fdf Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Wed, 7 Jun 2023 16:45:03 -0400 Subject: [PATCH 2/4] TST: Switch back to using testdir --- tests/test_doctestplus.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_doctestplus.py b/tests/test_doctestplus.py index a40597d..6e4148e 100644 --- a/tests/test_doctestplus.py +++ b/tests/test_doctestplus.py @@ -1144,17 +1144,17 @@ def foo(): result.assertoutcome(passed=2, failed=0) -def test_norecursedirs(pytester): - pytester.makeini( +def test_norecursedirs(testdir): + testdir.makeini( """ [pytest] norecursedirs = \"bad_dir\" doctestplus = enabled """ ) - subdir = pytester.mkdir("bad_dir") - with open(subdir / "test_foobar.py", "w") as fout: - fout.write(""" + subdir = testdir.mkdir("bad_dir") + badfile = subdir.join("test_foobar.py") + badfile.write_text(""" def f(): ''' >>> x = 1/3. @@ -1162,6 +1162,6 @@ def f(): 0.333333 ''' fail - """) - reprec = pytester.inline_run(pytester.path, "--doctest-plus") + """, "utf-8") + reprec = testdir.inline_run(str(testdir), "--doctest-plus") reprec.assertoutcome(failed=0, passed=0) From 884c6ce663d80441d42cb2f09f005798a34032f0 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Wed, 7 Jun 2023 16:59:58 -0400 Subject: [PATCH 3/4] Do not take over ignore collect to ensure compatibility with pytest 7.4 --- CHANGES.rst | 2 ++ pytest_doctestplus/plugin.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index c48aced..1cd774a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,8 @@ 0.12.2 (unreleased) =================== +- Compatibility with pytest 7.4 w.r.t. norecursedirs handling. [#201] + - Respect ``--doctest-continue-on-failure`` flag. [#197] - Report doctests raising skip exceptions as skipped. [#196] diff --git a/pytest_doctestplus/plugin.py b/pytest_doctestplus/plugin.py index 78235d1..e1cca3b 100644 --- a/pytest_doctestplus/plugin.py +++ b/pytest_doctestplus/plugin.py @@ -554,7 +554,7 @@ def get_list_opt(name): self._ignore_paths.append(path) break - return False + # None = Let other plugins decide the outcome. def pytest_collect_file(self, path, parent): """Implements an enhanced version of the doctest module from py.test From 8f251818528423b06e2eb6d49959aec92a1fbd25 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Wed, 7 Jun 2023 18:09:21 -0400 Subject: [PATCH 4/4] Improve change log message --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 1cd774a..cab88cc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,7 +1,7 @@ 0.12.2 (unreleased) =================== -- Compatibility with pytest 7.4 w.r.t. norecursedirs handling. [#201] +- Compatibility with pytest 7.4 with respect to ``norecursedirs`` handling. [#201] - Respect ``--doctest-continue-on-failure`` flag. [#197]