summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-05-08 15:17:31 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2017-05-08 15:17:31 +0200
commitb566ae2f14d36fc350462f3e927e4c48673d90a5 (patch)
treea5abd7d9347d5ef533859100f912b02a8cfaa981
parent950a57d7d3124f7e2f83cd439032848c69a03b33 (diff)
downloadpsutil-b566ae2f14d36fc350462f3e927e4c48673d90a5.tar.gz
#802 more tests
-rwxr-xr-xpsutil/tests/test_misc.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py
index 8953e31d..a55a24eb 100755
--- a/psutil/tests/test_misc.py
+++ b/psutil/tests/test_misc.py
@@ -403,13 +403,6 @@ class TestWrapNumbers(unittest.TestCase):
self.assertEqual(wrap_numbers(input, 'funname'), input)
def test_wrap_once(self):
- input = {'foo': nt(5, 5, 5)}
- self.assertEqual(wrap_numbers(input, 'funname'), input)
- input = {'foo': nt(5, 5, 3)}
- self.assertEqual(wrap_numbers(input, 'funname'),
- {'foo': nt(5, 5, 8)})
-
- def test_keep_wrapping(self):
input = {'foo': nt(100, 100, 100)}
self.assertEqual(wrap_numbers(input, 'funname'), input)
# wrap from 5, expect 105
@@ -421,6 +414,27 @@ class TestWrapNumbers(unittest.TestCase):
self.assertEqual(wrap_numbers(input, 'funname'),
{'foo': nt(100, 100, 115)})
+ def test_wrap_twice(self):
+ # let's say 100 is the threshold
+ input = {'foo': nt(100, 100, 100)}
+ self.assertEqual(wrap_numbers(input, 'funname'), input)
+ # first wrap restart from 10
+ input = {'foo': nt(100, 100, 10)}
+ self.assertEqual(wrap_numbers(input, 'funname'),
+ {'foo': nt(100, 100, 110)})
+ # then it goes on (90)
+ input = {'foo': nt(100, 100, 90)}
+ self.assertEqual(wrap_numbers(input, 'funname'),
+ {'foo': nt(100, 100, 200)})
+ # then it wraps again (5)
+ input = {'foo': nt(100, 100, 5)}
+ self.assertEqual(wrap_numbers(input, 'funname'),
+ {'foo': nt(100, 100, 205)})
+ # then another number wraps
+ input = {'foo': nt(100, 20, 205)}
+ self.assertEqual(wrap_numbers(input, 'funname'),
+ {'foo': nt(100, 120, 205)})
+
# ===================================================================
# --- Example script tests