diff options
Diffstat (limited to 'psutil/tests/test_linux.py')
-rwxr-xr-x | psutil/tests/test_linux.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index 964416b3..ac11017a 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -201,7 +201,7 @@ def get_free_version_info(): out = sh(["free", "-V"]).strip() if 'UNKNOWN' in out: raise unittest.SkipTest("can't determine free version") - return tuple(map(int, out.split()[-1].split('.'))) + return tuple(map(int, re.findall(r'\d+', out.split()[-1]))) @contextlib.contextmanager @@ -749,7 +749,7 @@ class TestSystemCPUCountLogical(PsutilTestCase): # this way we'll fall back on relying on /proc/stat with mock_open_content('/proc/cpuinfo', b"") as m: self.assertEqual(psutil._pslinux.cpu_count_logical(), original) - m.called + assert m.called @unittest.skipIf(not LINUX, "LINUX only") @@ -817,8 +817,8 @@ class TestSystemCPUFrequency(PsutilTestCase): self.assertEqual(ret.max, 0.0) self.assertEqual(ret.min, 0.0) for freq in psutil.cpu_freq(percpu=True): - self.assertEqual(ret.max, 0.0) - self.assertEqual(ret.min, 0.0) + self.assertEqual(freq.max, 0.0) + self.assertEqual(freq.min, 0.0) finally: reload_module(psutil._pslinux) reload_module(psutil) @@ -1057,7 +1057,7 @@ class TestSystemNetIOCounters(PsutilTestCase): def test_against_ifconfig(self): def ifconfig(nic): ret = {} - out = sh("ifconfig %s" % name) + out = sh("ifconfig %s" % nic) ret['packets_recv'] = int( re.findall(r'RX packets[: ](\d+)', out)[0]) ret['packets_sent'] = int( @@ -1150,7 +1150,7 @@ class TestSystemDiskPartitions(PsutilTestCase): for part in psutil.disk_partitions(all=False): usage = psutil.disk_usage(part.mountpoint) - dev, total, used, free = df(part.mountpoint) + _, total, used, free = df(part.mountpoint) self.assertEqual(usage.total, total) self.assertAlmostEqual(usage.free, free, delta=TOLERANCE_DISK_USAGE) @@ -2034,7 +2034,7 @@ class TestProcess(PsutilTestCase): # which no longer exists by the time we open() it (race # condition). threads() is supposed to ignore that instead # of raising NSP. - def open_mock(name, *args, **kwargs): + def open_mock_1(name, *args, **kwargs): if name.startswith('/proc/%s/task' % os.getpid()): raise IOError(errno.ENOENT, "") else: @@ -2042,20 +2042,20 @@ class TestProcess(PsutilTestCase): orig_open = open patch_point = 'builtins.open' if PY3 else '__builtin__.open' - with mock.patch(patch_point, side_effect=open_mock) as m: + with mock.patch(patch_point, side_effect=open_mock_1) as m: ret = psutil.Process().threads() assert m.called self.assertEqual(ret, []) # ...but if it bumps into something != ENOENT we want an # exception. - def open_mock(name, *args, **kwargs): + def open_mock_2(name, *args, **kwargs): if name.startswith('/proc/%s/task' % os.getpid()): raise IOError(errno.EPERM, "") else: return orig_open(name, *args, **kwargs) - with mock.patch(patch_point, side_effect=open_mock): + with mock.patch(patch_point, side_effect=open_mock_2): self.assertRaises(psutil.AccessDenied, psutil.Process().threads) def test_exe_mocked(self): |