diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-09-10 16:56:38 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-09-10 16:56:38 +0200 |
commit | a05713ec5332da168a4d01ce903780e50db8d51f (patch) | |
tree | 0aeff4084b32f1f3f4c63c7dae1e02bb892f1f91 | |
parent | d55984e5118722c0840374f8ddb0b4d72922510a (diff) | |
download | psutil-a05713ec5332da168a4d01ce903780e50db8d51f.tar.gz |
linux tests refactoring
-rw-r--r-- | psutil/tests/test_linux.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index 80f82c1d..4d4215f1 100644 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -55,6 +55,7 @@ if LINUX: # utils # ===================================================================== + def get_ipv4_address(ifname): import fcntl ifname = ifname[:15] @@ -90,7 +91,8 @@ def free_swap(): """Parse 'free' cmd and return swap memory's s total, used and free values. """ - lines = sh('free').split('\n') + out = sh('free') + lines = out.split('\n') for line in lines: if line.startswith('Swap'): _, total, used, free = line.split() @@ -107,7 +109,8 @@ def free_physmem(): # and 'cached' memory which may have different positions so we # do not return them. # https://github.com/giampaolo/psutil/issues/538#issuecomment-57059946 - lines = sh('free').split('\n') + out = sh('free') + lines = out.split('\n') for line in lines: if line.startswith('Mem'): total, used, free, shared = \ @@ -121,6 +124,7 @@ def free_physmem(): # system virtual memory # ===================================================================== + @unittest.skipUnless(LINUX, "not a Linux system") class TestSystemVirtualMemory(unittest.TestCase): @@ -187,6 +191,7 @@ class TestSystemVirtualMemory(unittest.TestCase): # system swap memory # ===================================================================== + @unittest.skipUnless(LINUX, "not a Linux system") class TestSystemSwapMemory(unittest.TestCase): @@ -248,6 +253,7 @@ class TestSystemSwapMemory(unittest.TestCase): # system CPU # ===================================================================== + @unittest.skipUnless(LINUX, "not a Linux system") class TestSystemCPU(unittest.TestCase): @@ -332,6 +338,7 @@ class TestSystemCPU(unittest.TestCase): # system network # ===================================================================== + @unittest.skipUnless(LINUX, "not a Linux system") class TestSystemNetwork(unittest.TestCase): @@ -442,6 +449,7 @@ class TestSystemNetwork(unittest.TestCase): # system disk # ===================================================================== + @unittest.skipUnless(LINUX, "not a Linux system") class TestSystemDisks(unittest.TestCase): @@ -602,6 +610,7 @@ class TestSystemDisks(unittest.TestCase): # misc # ===================================================================== + @unittest.skipUnless(LINUX, "not a Linux system") class TestMisc(unittest.TestCase): @@ -776,6 +785,7 @@ class TestMisc(unittest.TestCase): # test process # ===================================================================== + @unittest.skipUnless(LINUX, "not a Linux system") class TestProcess(unittest.TestCase): |