summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-05-08 17:32:28 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2017-05-08 17:32:28 +0200
commit26bcd9c85a2250a5ac34b6750615b5ba9cc1c002 (patch)
tree7a536170392fccfba25e8a9fde83730bac3f9807
parentb566ae2f14d36fc350462f3e927e4c48673d90a5 (diff)
downloadpsutil-26bcd9c85a2250a5ac34b6750615b5ba9cc1c002.tar.gz
#802: test driven development ;)
-rwxr-xr-xpsutil/tests/test_misc.py32
1 files changed, 12 insertions, 20 deletions
diff --git a/psutil/tests/test_misc.py b/psutil/tests/test_misc.py
index a55a24eb..a34224c7 100755
--- a/psutil/tests/test_misc.py
+++ b/psutil/tests/test_misc.py
@@ -401,20 +401,12 @@ class TestWrapNumbers(unittest.TestCase):
self.assertEqual(wrap_numbers(input, 'funname'), input)
input = {'foo': nt(10, 15, 20)}
self.assertEqual(wrap_numbers(input, 'funname'), input)
-
- def test_wrap_once(self):
- input = {'foo': nt(100, 100, 100)}
+ input = {'foo': nt(20, 25, 30)}
+ self.assertEqual(wrap_numbers(input, 'funname'), input)
+ input = {'foo': nt(20, 25, 30)}
self.assertEqual(wrap_numbers(input, 'funname'), input)
- # wrap from 5, expect 105
- input = {'foo': nt(100, 100, 5)}
- self.assertEqual(wrap_numbers(input, 'funname'),
- {'foo': nt(100, 100, 105)})
- # next go to 10, expect 115
- input = {'foo': nt(100, 100, 10)}
- self.assertEqual(wrap_numbers(input, 'funname'),
- {'foo': nt(100, 100, 115)})
- def test_wrap_twice(self):
+ def test_wrap(self):
# let's say 100 is the threshold
input = {'foo': nt(100, 100, 100)}
self.assertEqual(wrap_numbers(input, 'funname'), input)
@@ -422,18 +414,18 @@ class TestWrapNumbers(unittest.TestCase):
input = {'foo': nt(100, 100, 10)}
self.assertEqual(wrap_numbers(input, 'funname'),
{'foo': nt(100, 100, 110)})
- # then it goes on (90)
+ # then it remains the same
+ input = {'foo': nt(100, 100, 10)}
+ self.assertEqual(wrap_numbers(input, 'funname'),
+ {'foo': nt(100, 100, 110)})
+ # then it goes up (90, expect 200)
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)}
+ # then wrap again (expect 220)
+ input = {'foo': nt(100, 100, 20)}
self.assertEqual(wrap_numbers(input, 'funname'),
- {'foo': nt(100, 120, 205)})
+ {'foo': nt(100, 100, 220)})
# ===================================================================