Skip to content

Commit

Permalink
speed up some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Oct 29, 2014
1 parent 29b0a61 commit 7d41c28
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/test_psutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,10 @@ def test_process_iter(self):
p.wait()
self.assertNotIn(sproc.pid, [x.pid for x in psutil.process_iter()])

@retry_before_failing(50)
def test_process_iter_against_pids(self):
self.assertEqual(len(list(psutil.process_iter())), len(psutil.pids()))

def test_wait_procs(self):
l = []
callback = lambda p: l.append(p.pid)
Expand Down Expand Up @@ -862,20 +866,20 @@ def _test_cpu_percent(self, percent):

def test_sys_cpu_percent(self):
psutil.cpu_percent(interval=0.001)
for x in range(1000):
for x in range(100):
self._test_cpu_percent(psutil.cpu_percent(interval=None))

def test_sys_per_cpu_percent(self):
self.assertEqual(len(psutil.cpu_percent(interval=0.001, percpu=True)),
psutil.cpu_count())
for x in range(1000):
for x in range(100):
percents = psutil.cpu_percent(interval=None, percpu=True)
for percent in percents:
self._test_cpu_percent(percent)

def test_sys_cpu_times_percent(self):
psutil.cpu_times_percent(interval=0.001)
for x in range(1000):
for x in range(100):
cpu = psutil.cpu_times_percent(interval=None)
for percent in cpu:
self._test_cpu_percent(percent)
Expand All @@ -885,7 +889,7 @@ def test_sys_per_cpu_times_percent(self):
self.assertEqual(len(psutil.cpu_times_percent(interval=0.001,
percpu=True)),
psutil.cpu_count())
for x in range(1000):
for x in range(100):
cpus = psutil.cpu_times_percent(interval=None, percpu=True)
for cpu in cpus:
for percent in cpu:
Expand Down

0 comments on commit 7d41c28

Please sign in to comment.