Skip to content

(Pytest) Reload loop doesn't do fixture teardown #1

@rtpg

Description

@rtpg

Right now the pytest plugin is (roughly)

@pytest.hookimpl(tryfirst=True)
def pytest_pyfunc_call(pyfuncitem):
    if not plugin_enabled:
           return # don't do anything youreslf
    else:
          passing = False
          while not passing:
                   test_call_result = call_test(pyfuncitem)
                   passing = test_call_result.succeeded
                   if not passing:
                        enter_pdb(test_call_result)
          return

So you try running the test, and if it fails you fall into pdb and then run it again.

This will execute setup and teardown for some stuff but it won't do things like fixture resetting for those that require it. In particular for stuff like pytest-django's db marker, you end up not rollbacking the commit, so on subsequent runs things don't work well.

What likely needs to go on here is that we need to emulate fixture teardown and setup on failures (though trying to be smart about it....somehow). I think that only resetting function-scoped fixtures should do the job

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions