Skip to content

Commit

Permalink
Adjust tests for improved implementation of ** globs in Python 3.13+
Browse files Browse the repository at this point in the history
  • Loading branch information
hroncok committed Feb 6, 2024
1 parent 0fc6f9c commit 945f6b6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 945f6b6

Please sign in to comment.