-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add shell-style wildcard support to 'testpaths' #9897
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Added shell-style wildcard support to ``testpaths``. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,28 +244,32 @@ def test_testpaths_ini(self, pytester: Pytester, monkeypatch: MonkeyPatch) -> No | |
pytester.makeini( | ||
""" | ||
[pytest] | ||
testpaths = gui uts | ||
testpaths = */tests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this is a backwards-incompatible change (and thus a problem) if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for flagging that! I think I understand. The I think a backwards-compatible solution would apply some additional intelligence to the way I'm processing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe I have this working as intended in the latest revision. While this comment was associated with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jparise the real painful problem here is that "testpaths" is in fact only paths, not packages, pyargs was a tacked on hack to also look for tests in modules, its not soundly integrated i'd love to eventually be able to havea consistent idea of collection roots and test id sources There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RonnyPfannschmidt fortunately, I think we've arrived at a safe middle ground for this particular change, which only applies the |
||
""" | ||
) | ||
tmp_path = pytester.path | ||
ensure_file(tmp_path / "env" / "test_1.py").write_text("def test_env(): pass") | ||
ensure_file(tmp_path / "gui" / "test_2.py").write_text("def test_gui(): pass") | ||
ensure_file(tmp_path / "uts" / "test_3.py").write_text("def test_uts(): pass") | ||
ensure_file(tmp_path / "a" / "test_1.py").write_text("def test_a(): pass") | ||
ensure_file(tmp_path / "b" / "tests" / "test_2.py").write_text( | ||
"def test_b(): pass" | ||
) | ||
ensure_file(tmp_path / "c" / "tests" / "test_3.py").write_text( | ||
"def test_c(): pass" | ||
) | ||
|
||
# executing from rootdir only tests from `testpaths` directories | ||
# are collected | ||
items, reprec = pytester.inline_genitems("-v") | ||
assert [x.name for x in items] == ["test_gui", "test_uts"] | ||
assert [x.name for x in items] == ["test_b", "test_c"] | ||
|
||
# check that explicitly passing directories in the command-line | ||
# collects the tests | ||
for dirname in ("env", "gui", "uts"): | ||
for dirname in ("a", "b", "c"): | ||
items, reprec = pytester.inline_genitems(tmp_path.joinpath(dirname)) | ||
assert [x.name for x in items] == ["test_%s" % dirname] | ||
|
||
# changing cwd to each subdirectory and running pytest without | ||
# arguments collects the tests in that directory normally | ||
for dirname in ("env", "gui", "uts"): | ||
for dirname in ("a", "b", "c"): | ||
monkeypatch.chdir(pytester.path.joinpath(dirname)) | ||
items, reprec = pytester.inline_genitems() | ||
assert [x.name for x in items] == ["test_%s" % dirname] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a guess at the next version in which this might appear.