0

I have a directory with a bunch of modules. Each module has a bunch of specific tests. I know how to teardown after methods, classes and modules. What am trying to do is teardown after all the tests in all the modules in the directory are done running. My directory structure looks something like this:

enter image description here

I created this fixture in the conftest.py:

@pytest.yield_fixture(scope="package")
def **clean_cookie_file**():
  Path.unlink(filename)

Implemenatation of the fixture looks like this:

@pytest.mark.usefixtures("class_fixture", "**clean_cookie_file**")
class foo(unittest.TestCase):

Expected Result: file deleted

Actual Result: file not deleted

Any help will be much appreciated. Thank you guys

  • Have you tried to make your test classes inherit from a base class with the generic teardown? – João Farias Apr 27 at 5:41
  • Thank João. My test classes do indeed inherit from the base class. So if I add the tear down logic in the base class, where do I call it from considering that I want to make one teardown call at the end all the tests across all modules. – Aziz Apr 27 at 16:02
  • See stackoverflow.com/a/52873379 – bmshort Jun 20 at 21:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.