Skip to content

Commit

Permalink
Merge fc777a4 into 96da534
Browse files Browse the repository at this point in the history
  • Loading branch information
toddsifleet committed Apr 26, 2018
2 parents 96da534 + fc777a4 commit dc6e5ca
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
15 changes: 8 additions & 7 deletions doubles/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

from doubles.lifecycle import teardown, verify

def pytest_runtest_call(item):
def verify_and_teardown_doubles():
try:
verify()
finally:
teardown()
@pytest.hookimpl(hookwrapper=True)
def pytest_pyfunc_call(pyfuncitem):
outcome = yield

item.addfinalizer(verify_and_teardown_doubles)
try:
outcome.get_result()
verify()
finally:
teardown()
5 changes: 1 addition & 4 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
cov = coverage(source=('doubles',))
cov.start()

try:
from doubles.pytest_plugin import pytest_runtest_protocol # noqa
except ImportError:
from doubles.pytest_plugin import pytest_runtest_call # noqa
from doubles.pytest_plugin import pytest_pyfunc_call # noqa


def pytest_sessionfinish(session, exitstatus):
Expand Down
2 changes: 1 addition & 1 deletion test/pytest_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_that_should_fail_for_not_satisfying_expection():
""")
result = testdir.runpytest()
outcomes = result.parseoutcomes()
assert outcomes['error'] == 2
assert outcomes['failed'] == 2
expected_error = (
"*Expected 'class_method' to be called 1 time instead of 0 times on"
" <class 'doubles.testing.User'> with ('{arg_value}')*"
Expand Down

0 comments on commit dc6e5ca

Please sign in to comment.