summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-05-08 21:08:51 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2017-05-08 21:08:51 +0200
commit5141848f0e607c5894733297c46755be41af975c (patch)
tree63f10b252e2f6b2ab0442b652daada6448559273
parent726e179629273f7bae3e6b38262b2cd40f224746 (diff)
downloadpsutil-5141848f0e607c5894733297c46755be41af975c.tar.gz
#802: further tests for disappearing keys (impl is still broken)
-rw-r--r--psutil/_common.py2
-rwxr-xr-xpsutil/tests/test_misc.py11
2 files changed, 12 insertions, 1 deletions
diff --git a/psutil/_common.py b/psutil/_common.py
index 202c371a..bdfcefcd 100644
--- a/psutil/_common.py
+++ b/psutil/_common.py
@@ -495,8 +495,8 @@ def wrap_numbers(input_dict, name):
bits = []
for i in range(len(input_nt)):
- old_value = old_nt[i]
input_value = input_nt[i]
+ old_value = old_nt[i]
remkey = (name, key, i)
if input_value < old_value:
_wrapn_reminders[remkey] += old_value
diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py
index 112a3f38..3e2a3ce8 100755
--- a/psutil/tests/test_misc.py
+++ b/psutil/tests/test_misc.py
@@ -452,11 +452,22 @@ class TestWrapNumbers(unittest.TestCase):
# disk 2 disappears
input = {'disk1': nt(50, 50, 50)}
self.assertEqual(wrap_numbers(input, 'disk_io'), input)
+
# then it appears again; the old wrap is supposed to be
# gone.
input = {'disk1': nt(50, 50, 50),
'disk2': nt(100, 100, 100)}
self.assertEqual(wrap_numbers(input, 'disk_io'), input)
+ # remains the same
+ input = {'disk1': nt(50, 50, 50),
+ 'disk2': nt(100, 100, 100)}
+ self.assertEqual(wrap_numbers(input, 'disk_io'), input)
+ # and then wraps again
+ input = {'disk1': nt(50, 50, 50),
+ 'disk2': nt(100, 100, 10)}
+ self.assertEqual(wrap_numbers(input, 'disk_io'),
+ {'disk1': nt(50, 50, 50),
+ 'disk2': nt(100, 100, 110)})
# ===================================================================