@@ -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,25 @@ 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
+ # TODO: is this called when specifying direct filenames
166
+ # from command lines, eg.
167
+ # py.test test_a.py test_b.py
168
+ skipduplicates = config .getoption ("skipduplicates" )
169
+ duplicate_paths = config .pluginmanager ._duplicatepaths
170
+ if skipduplicates :
171
+ if path in duplicate_paths :
172
+ # TODO should we log this?
173
+ return True
174
+ else :
175
+ duplicate_paths .add (path )
176
+
177
+ return False
178
+
158
179
159
180
class FSHookProxy :
160
181
def __init__ (self , fspath , pm , remove_mods ):
0 commit comments