Merge pull request #9310 from bluetech/test-main-same-mod
testing/test_session: add a regression test for an old bug
This commit is contained in:
commit
0c8a54ab77
|
@ -335,6 +335,54 @@ def test_sessionfinish_with_start(pytester: Pytester) -> None:
|
||||||
assert res.ret == ExitCode.NO_TESTS_COLLECTED
|
assert res.ret == ExitCode.NO_TESTS_COLLECTED
|
||||||
|
|
||||||
|
|
||||||
|
def test_collection_args_do_not_duplicate_modules(pytester: Pytester) -> None:
|
||||||
|
"""Test that when multiple collection args are specified on the command line
|
||||||
|
for the same module, only a single Module collector is created.
|
||||||
|
|
||||||
|
Regression test for #723, #3358.
|
||||||
|
"""
|
||||||
|
pytester.makepyfile(
|
||||||
|
**{
|
||||||
|
"d/test_it": """
|
||||||
|
def test_1(): pass
|
||||||
|
def test_2(): pass
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
result = pytester.runpytest(
|
||||||
|
"--collect-only",
|
||||||
|
"d/test_it.py::test_1",
|
||||||
|
"d/test_it.py::test_2",
|
||||||
|
)
|
||||||
|
result.stdout.fnmatch_lines(
|
||||||
|
[
|
||||||
|
"<Module d/test_it.py>",
|
||||||
|
" <Function test_1>",
|
||||||
|
" <Function test_2>",
|
||||||
|
],
|
||||||
|
consecutive=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Different, but related case.
|
||||||
|
result = pytester.runpytest(
|
||||||
|
"--collect-only",
|
||||||
|
"--keep-duplicates",
|
||||||
|
"d",
|
||||||
|
"d",
|
||||||
|
)
|
||||||
|
result.stdout.fnmatch_lines(
|
||||||
|
[
|
||||||
|
"<Module d/test_it.py>",
|
||||||
|
" <Function test_1>",
|
||||||
|
" <Function test_2>",
|
||||||
|
" <Function test_1>",
|
||||||
|
" <Function test_2>",
|
||||||
|
],
|
||||||
|
consecutive=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("path", ["root", "{relative}/root", "{environment}/root"])
|
@pytest.mark.parametrize("path", ["root", "{relative}/root", "{environment}/root"])
|
||||||
def test_rootdir_option_arg(
|
def test_rootdir_option_arg(
|
||||||
pytester: Pytester, monkeypatch: MonkeyPatch, path: str
|
pytester: Pytester, monkeypatch: MonkeyPatch, path: str
|
||||||
|
|
Loading…
Reference in New Issue