diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-10-21 23:51:56 +0000 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-10-21 23:51:56 +0000 |
commit | d75bcb33b0d0b0a29b483a47a43e3aa4da1868fc (patch) | |
tree | 161c65c6c9fd170ddb0e45571e28b322bab1723b | |
parent | 28db82f7a934fbd01ccb724414d1f883ab8435a4 (diff) | |
download | psutil-d75bcb33b0d0b0a29b483a47a43e3aa4da1868fc.tar.gz |
fix tests
-rw-r--r-- | psutil/_psutil_posix.c | 8 | ||||
-rwxr-xr-x | psutil/tests/test_contracts.py | 26 | ||||
-rwxr-xr-x | psutil/tests/test_process.py | 5 |
3 files changed, 20 insertions, 19 deletions
diff --git a/psutil/_psutil_posix.c b/psutil/_psutil_posix.c index 11befdc6..d5567d3c 100644 --- a/psutil/_psutil_posix.c +++ b/psutil/_psutil_posix.c @@ -692,10 +692,6 @@ static PyMethodDef mod_methods[] = { if (PyModule_AddIntConstant(mod, "RLIMIT_FSIZE", RLIMIT_FSIZE)) INITERR; #endif -#ifdef RLIMIT_LOCKS - if (PyModule_AddIntConstant(mod, "RLIMIT_LOCKS", RLIMIT_LOCKS)) INITERR; -#endif - #ifdef RLIMIT_MEMLOCK if (PyModule_AddIntConstant(mod, "RLIMIT_MEMLOCK", RLIMIT_MEMLOCK)) INITERR; #endif @@ -718,6 +714,10 @@ static PyMethodDef mod_methods[] = { // Linux specific +#ifdef RLIMIT_LOCKS + if (PyModule_AddIntConstant(mod, "RLIMIT_LOCKS", RLIMIT_LOCKS)) INITERR; +#endif + #ifdef RLIMIT_MSGQUEUE if (PyModule_AddIntConstant(mod, "RLIMIT_MSGQUEUE", RLIMIT_MSGQUEUE)) INITERR; #endif diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py index 2d9e5917..b72bcd7b 100755 --- a/psutil/tests/test_contracts.py +++ b/psutil/tests/test_contracts.py @@ -89,19 +89,19 @@ class TestAvailConstantsAPIs(PsutilTestCase): @unittest.skipIf(GITHUB_WHEELS, "not exposed via GITHUB_WHEELS") def test_linux_rlimit(self): ae = self.assertEqual - ae(hasattr(psutil, "RLIM_INFINITY"), LINUX) - ae(hasattr(psutil, "RLIMIT_AS"), LINUX) - ae(hasattr(psutil, "RLIMIT_CORE"), LINUX) - ae(hasattr(psutil, "RLIMIT_CPU"), LINUX) - ae(hasattr(psutil, "RLIMIT_DATA"), LINUX) - ae(hasattr(psutil, "RLIMIT_FSIZE"), LINUX) - ae(hasattr(psutil, "RLIMIT_LOCKS"), LINUX) - ae(hasattr(psutil, "RLIMIT_MEMLOCK"), LINUX) - ae(hasattr(psutil, "RLIMIT_NOFILE"), LINUX) - ae(hasattr(psutil, "RLIMIT_NPROC"), LINUX) - ae(hasattr(psutil, "RLIMIT_RSS"), LINUX) - ae(hasattr(psutil, "RLIMIT_STACK"), LINUX) + ae(hasattr(psutil, "RLIM_INFINITY"), LINUX or FREEBSD) + ae(hasattr(psutil, "RLIMIT_AS"), LINUX or FREEBSD) + ae(hasattr(psutil, "RLIMIT_CORE"), LINUX or FREEBSD) + ae(hasattr(psutil, "RLIMIT_CPU"), LINUX or FREEBSD) + ae(hasattr(psutil, "RLIMIT_DATA"), LINUX or FREEBSD) + ae(hasattr(psutil, "RLIMIT_FSIZE"), LINUX or FREEBSD) + ae(hasattr(psutil, "RLIMIT_MEMLOCK"), LINUX or FREEBSD) + ae(hasattr(psutil, "RLIMIT_NOFILE"), LINUX or FREEBSD) + ae(hasattr(psutil, "RLIMIT_NPROC"), LINUX or FREEBSD) + ae(hasattr(psutil, "RLIMIT_RSS"), LINUX or FREEBSD) + ae(hasattr(psutil, "RLIMIT_STACK"), LINUX or FREEBSD) + ae(hasattr(psutil, "RLIMIT_LOCKS"), LINUX) ae(hasattr(psutil, "RLIMIT_MSGQUEUE"), LINUX) # requires Linux 2.6.8 ae(hasattr(psutil, "RLIMIT_NICE"), LINUX) # requires Linux 2.6.12 ae(hasattr(psutil, "RLIMIT_RTPRIO"), LINUX) # requires Linux 2.6.12 @@ -155,7 +155,7 @@ class TestAvailProcessAPIs(PsutilTestCase): @unittest.skipIf(GITHUB_WHEELS, "not exposed via GITHUB_WHEELS") def test_rlimit(self): # requires Linux 2.6.36 - self.assertEqual(hasattr(psutil.Process, "rlimit"), LINUX) + self.assertEqual(hasattr(psutil.Process, "rlimit"), LINUX or FREEBSD) def test_io_counters(self): hasit = hasattr(psutil.Process, "io_counters") diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index b2328ba2..0d63979b 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -448,8 +448,9 @@ class TestProcess(PsutilTestCase): self.assertEqual(p.rlimit(psutil.RLIMIT_NOFILE), (5, 5)) # If pid is 0 prlimit() applies to the calling process and # we don't want that. - with self.assertRaises(ValueError): - psutil._psplatform.Process(0).rlimit(0) + if LINUX: + with self.assertRaisesRegex(ValueError, "can't use prlimit"): + psutil._psplatform.Process(0).rlimit(0) with self.assertRaises(ValueError): p.rlimit(psutil.RLIMIT_NOFILE, (5, 5, 5)) |