Treat unittest.expectedFailure pass as a failure
This commit is contained in:
		
							parent
							
								
									10a6ed1707
								
							
						
					
					
						commit
						296f42a2c9
					
				|  | @ -228,10 +228,13 @@ def pytest_runtest_makereport(item, call): | ||||||
|     evalskip = getattr(item, '_evalskip', None) |     evalskip = getattr(item, '_evalskip', None) | ||||||
|     # unitttest special case, see setting of _unexpectedsuccess |     # unitttest special case, see setting of _unexpectedsuccess | ||||||
|     if hasattr(item, '_unexpectedsuccess') and rep.when == "call": |     if hasattr(item, '_unexpectedsuccess') and rep.when == "call": | ||||||
|         # we need to translate into how pytest encodes xpass |         # unittest treats an 'unexpected successes' as a failure | ||||||
|         rep.wasxfail = "reason: " + repr(item._unexpectedsuccess) |         # which means pytest needs to handle it like a 'xfail(strict=True)' | ||||||
|         # TODO: Do we need to check for strict xfail here as well? |         rep.outcome = "failed" | ||||||
|         rep.outcome = "passed" |         if item._unexpectedsuccess: | ||||||
|  |             rep.longrepr = "Unexpected success: {0}".format(item._unexpectedsuccess) | ||||||
|  |         else: | ||||||
|  |             rep.longrepr = "Unexpected success" | ||||||
|     elif item.config.option.runxfail: |     elif item.config.option.runxfail: | ||||||
|         pass   # don't interefere |         pass   # don't interefere | ||||||
|     elif call.excinfo and call.excinfo.errisinstance(pytest.xfail.Exception): |     elif call.excinfo and call.excinfo.errisinstance(pytest.xfail.Exception): | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue