summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpsutil/tests/test_linux.py19
-rwxr-xr-xpsutil/tests/test_system.py19
2 files changed, 9 insertions, 29 deletions
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py
index 77958ada..09fed4e4 100755
--- a/psutil/tests/test_linux.py
+++ b/psutil/tests/test_linux.py
@@ -842,25 +842,6 @@ class TestSystemCPUFrequency(unittest.TestCase):
freq = psutil.cpu_freq()
self.assertEqual(freq.current, 200)
- # Also test that NotImplementedError is raised in case no
- # current freq file is present.
-
- def open_mock(name, *args, **kwargs):
- if name.endswith('/scaling_cur_freq'):
- raise IOError(errno.ENOENT, "")
- elif name.endswith('/cpuinfo_cur_freq'):
- raise IOError(errno.ENOENT, "")
- elif name == '/proc/cpuinfo':
- raise IOError(errno.ENOENT, "")
- else:
- return orig_open(name, *args, **kwargs)
-
- orig_open = open
- patch_point = 'builtins.open' if PY3 else '__builtin__.open'
- with mock.patch(patch_point, side_effect=open_mock):
- with mock.patch('os.path.exists', return_value=True):
- self.assertRaises(NotImplementedError, psutil.cpu_freq)
-
@unittest.skipIf(not LINUX, "LINUX only")
class TestSystemCPUStats(unittest.TestCase):
diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py
index 83d7ef30..e04e120b 100755
--- a/psutil/tests/test_system.py
+++ b/psutil/tests/test_system.py
@@ -364,17 +364,16 @@ class TestSystemAPIs(unittest.TestCase):
# Simulate some work load then make sure time have increased
# between calls.
tot1 = psutil.cpu_times(percpu=True)
- stop_at = time.time() + 0.1
+ giveup_at = time.time() + 1
while True:
- if time.time() >= stop_at:
- break
- tot2 = psutil.cpu_times(percpu=True)
- for t1, t2 in zip(tot1, tot2):
- t1, t2 = sum(t1), sum(t2)
- difference = t2 - t1
- if difference >= 0.05:
- return
- self.fail()
+ if time.time() >= giveup_at:
+ return self.fail("timeout")
+ tot2 = psutil.cpu_times(percpu=True)
+ for t1, t2 in zip(tot1, tot2):
+ t1, t2 = psutil._cpu_busy_time(t1), psutil._cpu_busy_time(t2)
+ difference = t2 - t1
+ if difference >= 0.05:
+ return
def test_cpu_times_comparison(self):
# Make sure the sum of all per cpu times is almost equal to