Skip to content

Instantly share code, notes, and snippets.

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