-
Notifications
You must be signed in to change notification settings - Fork 74
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
Router problem with TestClient #473
Comments
@kika115 could you provide an example of code? I have this fixture and it works well for me. @pytest.fixture
async def api_client(mongodb, init_db) -> AuthTestClient:
from tmw_server.app import app
await app.start()
return AuthTestClient(app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have a pytest fixture designed to create a new application instance for each test, specifically for use with a test client. The primary challenge I am facing is related to the router within the application. The first test executes correctly, with the router functioning as expected. However, for all subsequent tests, the router appears to be empty.
The core of the problem seems to be tied to the router validation process and its reinitialization. While the validation of routers successfully passes in each test iteration, the router remains empty after the first test. This suggests that after resetting, the router is not being properly reloaded or reinitialized in the new instances of the application created for each test.
This issue is critical because the router's state is essential for handling requests and routing them to the correct endpoints. The empty router in subsequent tests implies that the application is unable to process any requests, rendering these tests ineffective.
The text was updated successfully, but these errors were encountered: