feature: default behavior now is to ignore duplicate paths specified from the command line. Use --keep-duplicates to retain duplicate paths.
This commit is contained in:
@@ -1213,3 +1213,40 @@ def test_syntax_error_with_non_ascii_chars(testdir):
|
||||
'*SyntaxError*',
|
||||
'*1 error in*',
|
||||
])
|
||||
|
||||
|
||||
def test_skip_duplicates_by_default(testdir):
|
||||
"""Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609)
|
||||
|
||||
Ignore duplicate directories.
|
||||
"""
|
||||
a = testdir.mkdir("a")
|
||||
fh = a.join("test_a.py")
|
||||
fh.write(_pytest._code.Source("""
|
||||
import pytest
|
||||
def test_real():
|
||||
pass
|
||||
"""))
|
||||
result = testdir.runpytest(a.strpath, a.strpath)
|
||||
result.stdout.fnmatch_lines([
|
||||
'*collected 1 item*',
|
||||
])
|
||||
|
||||
|
||||
|
||||
def test_keep_duplicates(testdir):
|
||||
"""Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609)
|
||||
|
||||
Use --keep-duplicates to collect tests from duplicate directories.
|
||||
"""
|
||||
a = testdir.mkdir("a")
|
||||
fh = a.join("test_a.py")
|
||||
fh.write(_pytest._code.Source("""
|
||||
import pytest
|
||||
def test_real():
|
||||
pass
|
||||
"""))
|
||||
result = testdir.runpytest("--keep-duplicates", a.strpath, a.strpath)
|
||||
result.stdout.fnmatch_lines([
|
||||
'*collected 2 item*',
|
||||
])
|
||||
|
||||
@@ -973,7 +973,7 @@ class TestMetafuncFunctional:
|
||||
"""))
|
||||
sub1.join("test_in_sub1.py").write("def test_1(): pass")
|
||||
sub2.join("test_in_sub2.py").write("def test_2(): pass")
|
||||
result = testdir.runpytest("-v", "-s", sub1, sub2, sub1)
|
||||
result = testdir.runpytest("--keep-duplicates", "-v", "-s", sub1, sub2, sub1)
|
||||
result.assert_outcomes(passed=3)
|
||||
|
||||
def test_generate_same_function_names_issue403(self, testdir):
|
||||
|
||||
Reference in New Issue
Block a user