Example needed of fixture cleanup
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.
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.
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)