From 945f6b6c23cd9eeb770f09460caceba2fa522abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Tue, 6 Feb 2024 12:58:07 +0100 Subject: [PATCH] Adjust tests for improved implementation of ** globs in Python 3.13+ https://docs.python.org/dev/library/glob.html#glob.translate https://docs.python.org/3.13/whatsnew/3.13.html#changes-in-the-python-api https://github.com/python/cpython/issues/70303 --- tests/test_functional.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_functional.py b/tests/test_functional.py index a55f4b7..e73c401 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -161,12 +161,18 @@ def test_filter_fnmatch_pattern(tmp_path: Path, capsys: CaptureFixture[str], run write_config(tmp_path, runner, pattern="'**/*.rst'") results = run(capsys, runner, tmp_path) # The fact that the two .rst files in the root aren't matched is - # arguably a bug in the Python interpretation of **/ + # arguably a bug in the Python interpretation of **/ in Python < 3.13 + expected_total = 4 results.out.assert_has_run(runner, '/parent/foo.rst') results.out.assert_has_run(runner, '/parent/bar.rst') results.out.assert_has_run(runner, '/parent/child/foo.rst') results.out.assert_has_run(runner, '/parent/child/bar.rst') - assert results.total == 4, results.out.text + # The interpretation of **/ was fixed in Python 3.13 + if sys.version_info >= (3, 13): + expected_total = 6 + results.out.assert_has_run(runner, '/foo.rst') + results.out.assert_has_run(runner, '/bar.rst') + assert results.total == expected_total, results.out.text @pytest.mark.parametrize('runner', [PYTEST, UNITTEST]) @@ -214,7 +220,7 @@ def test_filter_filenames_and_excludes(tmp_path: Path, capsys: CaptureFixture[st write_config(tmp_path, runner, path=f"'{tmp_path / 'parent'}'", filenames="{'bar.rst'}", - excludes="['**child/*.rst']") + excludes="['**/child/*.rst']") results = run(capsys, runner, tmp_path) results.out.assert_has_run(runner, '/parent/bar.rst') assert results.total == 1, results.out.text