Skip to content

Commit

Permalink
fix more CentOS failures
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Oct 10, 2019
1 parent af4b6c0 commit 63fcc0e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 29 deletions.
19 changes: 0 additions & 19 deletions psutil/tests/test_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,25 +842,6 @@ def open_mock(name, *args, **kwargs):
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):
Expand Down
19 changes: 9 additions & 10 deletions psutil/tests/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,16 @@ def test_per_cpu_times_2(self):
# 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
Expand Down

0 comments on commit 63fcc0e

Please sign in to comment.