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

[BUG] Python asyncio tests are not closing API Client #19998

Open
3 of 6 tasks
AngellusMortis opened this issue Oct 30, 2024 · 2 comments
Open
3 of 6 tasks

[BUG] Python asyncio tests are not closing API Client #19998

AngellusMortis opened this issue Oct 30, 2024 · 2 comments

Comments

@AngellusMortis
Copy link

AngellusMortis commented Oct 30, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
openapi-generator version

7.9.0

OpenAPI declaration file content or url

https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml

Generation Details
Steps to reproduce
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g python -p library=asyncio -o /local/out/python

python -m venv venv
pip install -r requirements.txt -r test-requirements.txt
pytest

Pytest fill give a warning for each API class similar to the following:

Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f39496c5160>                                                                                                                                                                                     
Related issues/PRs
Suggest a fix

For any of the TestXXXXXApi test classes, just replace the following:

    async def asyncTearDown(self) -> None:
        pass

with

    async def asyncTearDown(self) -> None:
        await self.api.api_client.close()

(for example for the PetStore API spec, it is test/test_pet_api.py:TestPetApi)

@wing328
Copy link
Member

wing328 commented Oct 31, 2024

can you please file a PR with the suggested fix when you've time?

@AngellusMortis
Copy link
Author

No, I cannot. I was not even supposed to make the issue. Sorry, I work for one of those orgs that are super hostile against contributing to open source.

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

Successfully merging a pull request may close this issue.

2 participants