@@ -34,6 +34,12 @@ def pytest_addoption(parser):
3434 dest = "attach_capture" ,
3535 help = "Do not attach pytest captured logging/stdout/stderr to report" )
3636
37+ parser .getgroup ("reporting" ).addoption ('--inversion' ,
38+ action = "store" ,
39+ dest = "inversion" ,
40+ default = False ,
41+ help = "Run tests not in testplan" )
42+
3743 def label_type (type_name , legal_values = set ()):
3844 def a_label_type (string ):
3945 atoms = set (string .split (',' ))
@@ -165,8 +171,9 @@ def select_by_labels(items, config):
165171 return items , []
166172
167173
168- def select_by_testcase (items ):
174+ def select_by_testcase (items , config ):
169175 planned_tests = get_testplan ()
176+ is_inversion = config .option .inversion
170177
171178 if planned_tests :
172179
@@ -180,8 +187,8 @@ def is_planed(item):
180187 planed_item_string_id in allure_string_ids
181188 or planed_item_selector == allure_full_name (item )
182189 ):
183- return True
184- return False
190+ return True if not is_inversion else False
191+ return False if not is_inversion else True
185192
186193 selected , deselected = [], []
187194 for item in items :
@@ -192,7 +199,7 @@ def is_planed(item):
192199
193200
194201def pytest_collection_modifyitems (items , config ):
195- selected , deselected_by_testcase = select_by_testcase (items )
202+ selected , deselected_by_testcase = select_by_testcase (items , config )
196203 selected , deselected_by_labels = select_by_labels (selected , config )
197204
198205 items [:] = selected
0 commit comments