Last active
August 29, 2015 14:06
-
-
Save weissjeffm/fcd7e5b311eb5ae35503 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| In [7]: | |
| def mytest(): | |
| print "running test" | |
| def cleanup(): | |
| print "cleaning up test" | |
| raise Exception({'msg': 'oh noes', 'cleanup': cleanup}) | |
| def pytest_exception_interact(e): | |
| print "handling error" | |
| e.message['cleanup']() | |
| def pytest_test_runner(test): | |
| try: | |
| print "starting test" | |
| test() | |
| except Exception as e: | |
| print "test failed" | |
| pytest_exception_interact(e) | |
| finally: | |
| print "pytest cleaning up" | |
| pytest_test_runner(mytest) | |
| starting test | |
| running test | |
| test failed | |
| handling error | |
| cleaning up test | |
| pytest cleaning up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment