forked from com2ghz/openapi-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[python/asyncio] explicitly close client session via async context ma…
…nager (OpenAPITools#5621)
- Loading branch information
1 parent
320e3c5
commit e5ee9f5
Showing
7 changed files
with
58 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
samples/client/petstore/python-asyncio/tests/test_api_client.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# coding: utf-8 | ||
|
||
# flake8: noqa | ||
|
||
import unittest | ||
import weakref | ||
|
||
from tests.util import async_test | ||
import petstore_api | ||
|
||
|
||
class TestApiClient(unittest.TestCase): | ||
|
||
@async_test | ||
async def test_context_manager_closes_client(self): | ||
|
||
async with petstore_api.ApiClient() as client: | ||
# thread pool | ||
self.assertIsNotNone(client.pool) | ||
pool_ref = weakref.ref(client._pool) | ||
self.assertIsNotNone(pool_ref()) | ||
# pool_manager | ||
self.assertFalse(client.rest_client.pool_manager.closed) | ||
rest_pool_ref = client.rest_client.pool_manager | ||
|
||
self.assertIsNone(pool_ref()) | ||
self.assertTrue(rest_pool_ref.closed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters