forked from kubernetes-client/python
-
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.
Signed-off-by: Nabarun Pal <[email protected]>
- Loading branch information
1 parent
c55930b
commit 4fd43bc
Showing
3 changed files
with
44 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from __future__ import absolute_import | ||
import warnings | ||
|
||
# flake8: noqa | ||
|
||
# alias kubernetes.client.api package and print deprecation warning | ||
from kubernetes.client.api import * | ||
|
||
warnings.filterwarnings('default', module='kubernetes.client.apis') | ||
warnings.warn( | ||
"The package kubernetes.client.apis is renamed and deprecated, use kubernetes.client.api instead (please note that the trailing s was removed).", | ||
DeprecationWarning | ||
) |
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,25 @@ | ||
# coding: utf-8 | ||
|
||
|
||
import atexit | ||
import weakref | ||
import unittest | ||
|
||
import kubernetes | ||
|
||
|
||
class TestApiClient(unittest.TestCase): | ||
|
||
def test_context_manager_closes_threadpool(self): | ||
with kubernetes.client.ApiClient() as client: | ||
self.assertIsNotNone(client.pool) | ||
pool_ref = weakref.ref(client._pool) | ||
self.assertIsNotNone(pool_ref()) | ||
self.assertIsNone(pool_ref()) | ||
|
||
def test_atexit_closes_threadpool(self): | ||
client = kubernetes.client.ApiClient() | ||
self.assertIsNotNone(client.pool) | ||
self.assertIsNotNone(client._pool) | ||
atexit._run_exitfuncs() | ||
self.assertIsNone(client._pool) |