diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-01-07 16:45:44 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-01-07 16:45:44 +0100 |
commit | eb5ee07c544cfc90e20b3cbd262a9c9c4e8af363 (patch) | |
tree | ff2066602ecd9191f3c6f7f69e232ad0ac4f64e8 | |
parent | 57356c43cae11322f9ef7d1e882e3c9954736b7b (diff) | |
download | psutil-eb5ee07c544cfc90e20b3cbd262a9c9c4e8af363.tar.gz |
add contract tests for IOPRIO_ win constants
-rwxr-xr-x | psutil/tests/test_contracts.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py index 4f179c40..6d016779 100755 --- a/psutil/tests/test_contracts.py +++ b/psutil/tests/test_contracts.py @@ -66,13 +66,20 @@ class TestAvailConstantsAPIs(unittest.TestCase): ae(hasattr(psutil, "NORMAL_PRIORITY_CLASS"), WINDOWS) ae(hasattr(psutil, "REALTIME_PRIORITY_CLASS"), WINDOWS) - def test_linux_ioprio(self): + def test_linux_ioprio_linux(self): ae = self.assertEqual ae(hasattr(psutil, "IOPRIO_CLASS_NONE"), LINUX) ae(hasattr(psutil, "IOPRIO_CLASS_RT"), LINUX) ae(hasattr(psutil, "IOPRIO_CLASS_BE"), LINUX) ae(hasattr(psutil, "IOPRIO_CLASS_IDLE"), LINUX) + def test_linux_ioprio_windows(self): + ae = self.assertEqual + ae(hasattr(psutil, "IOPRIO_HIGH"), WINDOWS) + ae(hasattr(psutil, "IOPRIO_NORMAL"), WINDOWS) + ae(hasattr(psutil, "IOPRIO_LOW"), WINDOWS) + ae(hasattr(psutil, "IOPRIO_VERYLOW"), WINDOWS) + def test_linux_rlimit(self): ae = self.assertEqual hasit = LINUX and get_kernel_version() >= (2, 6, 36) @@ -453,16 +460,20 @@ class TestFetchAllProcesses(unittest.TestCase): self.assertGreaterEqual(field, 0) def ionice(self, ret, proc): - if POSIX: - assert is_namedtuple(ret) - for field in ret: - self.assertIsInstance(field, int) if LINUX: + self.assertIsInstance(ret.ioclass, int) + self.assertIsInstance(ret.value, int) self.assertGreaterEqual(ret.ioclass, 0) self.assertGreaterEqual(ret.value, 0) - else: + else: # Windows, Cygwin + choices = [ + psutil.IOPRIO_VERYLOW, + psutil.IOPRIO_LOW, + psutil.IOPRIO_NORMAL, + psutil.IOPRIO_HIGH] + self.assertIsInstance(ret, int) self.assertGreaterEqual(ret, 0) - self.assertIn(ret, (0, 1, 2)) + self.assertIn(ret, choices) def num_threads(self, ret, proc): self.assertIsInstance(ret, int) |