Last active
August 29, 2015 14:23
-
-
Save hjwp/5154ec40a476a5c01ba6 to your computer and use it in GitHub Desktop.
pytest finalizer that prints?
This file contains 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
import pytest | |
@pytest.yield_fixture | |
def print_on_fail(): | |
yield | |
print('test failed') |
This file contains 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
from thing import do_stuff | |
def test_doing_stuff(print_on_fail): | |
assert do_stuff() == 42 | |
assert do_stuff() == 43 |
This file contains 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
def do_stuff(): | |
return 42 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment