stepwise: report status via pytest_report_collectionfinish
This commit is contained in:
		
							parent
							
								
									15d608867d
								
							
						
					
					
						commit
						94a2e3dddc
					
				|  | @ -0,0 +1 @@ | |||
| The stepwise plugin reports status information now. | ||||
|  | @ -8,7 +8,7 @@ def pytest_addoption(parser): | |||
|         "--stepwise", | ||||
|         action="store_true", | ||||
|         dest="stepwise", | ||||
|         help="exit on test fail and continue from last failing test next time", | ||||
|         help="exit on test failure and continue from last failing test next time", | ||||
|     ) | ||||
|     group.addoption( | ||||
|         "--stepwise-skip", | ||||
|  | @ -37,7 +37,10 @@ class StepwisePlugin: | |||
|         self.session = session | ||||
| 
 | ||||
|     def pytest_collection_modifyitems(self, session, config, items): | ||||
|         if not self.active or not self.lastfailed: | ||||
|         if not self.active: | ||||
|             return | ||||
|         if not self.lastfailed: | ||||
|             self.report_status = "no previously failed tests, not skipping." | ||||
|             return | ||||
| 
 | ||||
|         already_passed = [] | ||||
|  | @ -54,7 +57,12 @@ class StepwisePlugin: | |||
|         # If the previously failed test was not found among the test items, | ||||
|         # do not skip any tests. | ||||
|         if not found: | ||||
|             self.report_status = "previously failed test not found, not skipping." | ||||
|             already_passed = [] | ||||
|         else: | ||||
|             self.report_status = "skipping {} already passed items.".format( | ||||
|                 len(already_passed) | ||||
|             ) | ||||
| 
 | ||||
|         for item in already_passed: | ||||
|             items.remove(item) | ||||
|  | @ -94,6 +102,10 @@ class StepwisePlugin: | |||
|                 if report.nodeid == self.lastfailed: | ||||
|                     self.lastfailed = None | ||||
| 
 | ||||
|     def pytest_report_collectionfinish(self): | ||||
|         if self.active and self.config.getoption("verbose") >= 0: | ||||
|             return "stepwise: %s" % self.report_status | ||||
| 
 | ||||
|     def pytest_sessionfinish(self, session): | ||||
|         if self.active: | ||||
|             self.config.cache.set("cache/stepwise", self.lastfailed) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue