summaryrefslogtreecommitdiff
path: root/psutil/tests/test_misc.py
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-05-09 04:25:33 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2017-05-09 04:25:33 +0200
commit29ca4c2e11975decb7035582922ecada67a64c49 (patch)
treec8e85235c34031df9311120bd9ddf9e545d4d1f0 /psutil/tests/test_misc.py
parentf56a5e8102fe2c2e37792ea1171507a242421651 (diff)
downloadpsutil-29ca4c2e11975decb7035582922ecada67a64c49.tar.gz
add test
Diffstat (limited to 'psutil/tests/test_misc.py')
-rwxr-xr-xpsutil/tests/test_misc.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py
index 676c7554..fe582a77 100755
--- a/psutil/tests/test_misc.py
+++ b/psutil/tests/test_misc.py
@@ -68,8 +68,12 @@ import psutil
import psutil.tests
+# ===================================================================
+# --- Misc / generic tests.
+# ===================================================================
+
+
class TestMisc(unittest.TestCase):
- """Misc / generic tests."""
def test_process__repr__(self, func=repr):
p = psutil.Process()
@@ -379,6 +383,11 @@ class TestMisc(unittest.TestCase):
self.assertIn("version conflict", str(cm.exception).lower())
+# ===================================================================
+# --- Tests for wrap_numbers() function.
+# ===================================================================
+
+
nt = namedtuple('foo', 'a b c')
@@ -570,6 +579,15 @@ class TestWrapNumbers(unittest.TestCase):
{'disk_io': {('disk1', 0): 0, ('disk1', 1): 0, ('disk1', 2): 0}})
self.assertEqual(cache[2], {'disk_io': {}})
+ def test_cache_clear(self):
+ input = {'disk1': nt(5, 5, 5)}
+ wrap_numbers(input, 'disk_io')
+ wrap_numbers(input, 'disk_io')
+ wrap_numbers.cache_clear('disk_io')
+ self.assertEqual(wrap_numbers.cache_info(), ({}, {}, {}))
+ wrap_numbers.cache_clear('disk_io')
+ wrap_numbers.cache_clear('?!?')
+
# ===================================================================
# --- Example script tests