-
Notifications
You must be signed in to change notification settings - Fork 452
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
Make rest_api
fixture async
#7522
Conversation
d60cb1e
to
add0fec
Compare
add0fec
to
a98e596
Compare
2ebe49e
to
27844e3
Compare
I'll squash commits at the end, after review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the effort in making the rest_api
fixture async, as it streamlines the code used in async tests. However, there are some aspects of the PR that need attention and possible revision:
-
The PR description mentions fixing the
app.shutdown()
call by addingawait
, but this change has already been addressed in PR Fix callingawait app.shutdown()
in REST API tests #7502. Please update the PR description to reflect only the changes made in this PR. -
The removal of the
web_app
fixture has led to duplication of theapp = Application(...) / ... / await app.shutdown()
sequence in 14 different places. The original fixture centralized this logic. Can you elaborate on the benefit of removing it? -
It's great that this PR addresses the calling of the
shutdown
methods of specific endpoints used in tests. However, this isn't mentioned in the PR description. Please update the description to include this critical fix. Also, it would be ideal if, in the future,app.shutdown()
could automatically handle the shutdown of endpoints, though this should be approached cautiously. -
The removal of the
event_loop
fixture needs justification. It was initially introduced in PR Replace theloop
fixture with theevent_loop
fixture. #7168 to resolve the "Asyncio Event Loop is Closed" issue on Windows by employingWindowsSelectorEventLoopPolicy
andnew_event_loop()
. Please either provide a rationale for its removal or consider reinstating it, as it apparently fixed important issues on Windows.
Thank you for your contributions. Please address these points to ensure that the PR accurately reflects its changes and maintains code quality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the event_loop fixture removal, the rest is OK to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the Slack discussion, I'm okay with the approach to see if event_loop is required based on future test results, in which case, it can be reverted if the event loop issue reoccurs. For now, I approve the PR.
@kozlovsky I appreciate your appreciation in effort in making the The PR's title and description are sufficiently descriptive since the main change is converting the Does the following change truly require a further detailed description due to its complexity? @pytest.fixture
def rest_api(event_loop, aiohttp_client, knowledge_endpoint):
app = Application()
app.add_subapp('/knowledge', knowledge_endpoint.app)
yield event_loop.run_until_complete(aiohttp_client(app))
app.shutdown() @pytest.fixture
async def rest_api(aiohttp_client, knowledge_endpoint):
app = Application()
app.add_subapp('/knowledge', knowledge_endpoint.app)
yield await aiohttp_client(app)
await app.shutdown() The intention behind introducing As for the removal of |
27844e3
to
2a257f1
Compare
I plan to address the duplication of |
I'd say overwriting the code that is already (at that moment) in the main branch is not the same as "avoiding the merge conflicts." If the repo already has the merge conflict, and one PR is already in the repo while the other PR is going through the review, solving the merge conflict usually does not mean that you completely override the code of the existing PR with your code. |
This PR fixes
rest_api
by making it async.Previously the common pattern was:
which is incorrect as
app.shutdown()
is async call.Additionally, this PR includes some minor refactoring.
Related to #7495