BlackSheep
BlackSheep copied to clipboard
Router problem with TestClient
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.