getsentry / pytest-responses

py.test integration for responses

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

error during teardown on skipping tests.

aodag opened this issue · comments

if first test was skipped, we got error in teardown for pytest_responses.
because pytest_runtest_setup is not called on skipping tests but pytest_runtest_teardown is called.

see pytest-dev/pytest#3385

___________________________________________________________________________________________ ERROR at teardown of test1 ____________________________________________________________________________________________

item = <Function test1>

    def pytest_runtest_teardown(item):
        if not get_withoutresponses_marker(item):
            try:
>               responses_.stop()

../../.local/share/virtualenvs/pytest_sample-j3KXi7ce/lib/python3.7/site-packages/pytest_responses.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <responses.RequestsMock object at 0x7fe17f370d30>, allow_assert = True

    def stop(self, allow_assert=True):
>       self._patcher.stop()
E       AttributeError: 'RequestsMock' object has no attribute '_patcher'

This issue is creating many phantom build failures for us. Is anything keeping the PR from landing?

@getsentry any updates on the PR?

@f213 your fix definitely works, it means I can now run my tests in parallel with a combination of pytest-xdist and pytest-run :)