Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example needed of fixture cleanup #10

Open
jinnatar opened this issue Sep 3, 2019 · 2 comments
Open

Example needed of fixture cleanup #10

jinnatar opened this issue Sep 3, 2019 · 2 comments

Comments

@jinnatar
Copy link

jinnatar commented Sep 3, 2019

With the way the example fixtures are built it's not obvious how to change to a yield & do cleanup -style fixture.
When testing against a real service even in a testing environment it becomes necessary to run cleanup code for guaranteeing clean results every time.

@awichmann-mintel
Copy link

Yeah. I think there is also a problem with the module scoped grpc_server fixture. This makes it impossible to clean up calls made to the servicer between individual test functions.

@curtiscook
Copy link

Old issue, but it looks like a couple of people ran into this, and it's more of a pytest question.

I would create an additional fixture and enable auto-use. This lets the fixture be attached to every test without adding an import.

Example:

@pytest.fixture(scope="function", autouse=True)
def cleanup_grpc() -> None:
  <cleanup code here (or yield then clean after)> 

Recreating the server for every test seems inefficient, so I think session or module is the appropriate scope. (This is similar to how setUp/tearDown work in UnitTest)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants