@@ -63,6 +63,9 @@ def pytest_addoption(parser):
63
63
group .addoption ('--noconftest' , action = "store_true" ,
64
64
dest = "noconftest" , default = False ,
65
65
help = "Don't load any conftest.py files." )
66
+ group .addoption ('--skipduplicates' , '--skip-duplicates' , action = "store_true" ,
67
+ dest = "skipduplicates" , default = False ,
68
+ help = "Skip duplicate tests." )
66
69
67
70
group = parser .getgroup ("debugconfig" ,
68
71
"test session debugging and configuration" )
@@ -154,7 +157,22 @@ def pytest_ignore_collect(path, config):
154
157
excludeopt = config .getoption ("ignore" )
155
158
if excludeopt :
156
159
ignore_paths .extend ([py .path .local (x ) for x in excludeopt ])
157
- return path in ignore_paths
160
+
161
+ if path in ignore_paths :
162
+ return True
163
+
164
+ # Skip duplicate paths.
165
+ skipduplicates = config .getoption ("skipduplicates" )
166
+ duplicate_paths = config .pluginmanager ._skipduplicates
167
+ if skipduplicates :
168
+ if path .purebasename in duplicate_paths :
169
+ # TODO should we log this?
170
+ return True
171
+ else :
172
+ duplicate_paths .add (path .purebasename )
173
+
174
+ return False
175
+
158
176
159
177
class FSHookProxy :
160
178
def __init__ (self , fspath , pm , remove_mods ):
0 commit comments