summaryrefslogtreecommitdiff
path: root/psutil/tests/test_linux.py
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-05-10 20:38:05 +0200
committerGitHub <noreply@github.com>2017-05-10 20:38:05 +0200
commit58aef46d74ff577f60eb9e0478d6de3361c8a4e9 (patch)
treefea3e3cf33de981dd1d54d12cb7f718876d3b244 /psutil/tests/test_linux.py
parent596b43381711248093caf1c1df3b5d93d0c70bb6 (diff)
downloadpsutil-58aef46d74ff577f60eb9e0478d6de3361c8a4e9.tar.gz
1058 enable fix warnings (#1059)
* #1058: have Makefile use PYTHONWARNINGS=all by default for (almost) all commands * #1058 fix linux tests warnings * #1058: try not to use imp module * #1058: get rid of imp module completely * #1058: ignore unicode warnings * #1058: ignore stderr from procsmem.py * #1058: fix resource warning from Popen * #1058: get rid of contextlib.nested (deprecated)
Diffstat (limited to 'psutil/tests/test_linux.py')
-rwxr-xr-xpsutil/tests/test_linux.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py
index 4adcb376..2054da8b 100755
--- a/psutil/tests/test_linux.py
+++ b/psutil/tests/test_linux.py
@@ -30,12 +30,12 @@ from psutil._compat import u
from psutil.tests import call_until
from psutil.tests import HAS_BATTERY
from psutil.tests import HAS_RLIMIT
-from psutil.tests import importlib
from psutil.tests import MEMORY_TOLERANCE
from psutil.tests import mock
from psutil.tests import PYPY
from psutil.tests import pyrun
from psutil.tests import reap_children
+from psutil.tests import reload_module
from psutil.tests import retry_before_failing
from psutil.tests import run_test_module_by_name
from psutil.tests import safe_rmpath
@@ -324,9 +324,13 @@ class TestSystemVirtualMemory(unittest.TestCase):
orig_open = open
patch_point = 'builtins.open' if PY3 else '__builtin__.open'
with mock.patch(patch_point, create=True, side_effect=open_mock) as m:
- ret = psutil.virtual_memory()
+ with warnings.catch_warnings(record=True) as ws:
+ ret = psutil.virtual_memory()
assert m.called
self.assertEqual(ret.available, 6574984 * 1024)
+ w = ws[0]
+ self.assertIn(
+ "inactive memory stats couldn't be determined", str(w.message))
def test_avail_old_missing_fields(self):
# Remove Active(file), Inactive(file) and SReclaimable
@@ -351,9 +355,13 @@ class TestSystemVirtualMemory(unittest.TestCase):
orig_open = open
patch_point = 'builtins.open' if PY3 else '__builtin__.open'
with mock.patch(patch_point, create=True, side_effect=open_mock) as m:
- ret = psutil.virtual_memory()
+ with warnings.catch_warnings(record=True) as ws:
+ ret = psutil.virtual_memory()
assert m.called
self.assertEqual(ret.available, 2057400 * 1024 + 4818144 * 1024)
+ w = ws[0]
+ self.assertIn(
+ "inactive memory stats couldn't be determined", str(w.message))
def test_avail_old_missing_zoneinfo(self):
# Remove /proc/zoneinfo file. Make sure fallback is used
@@ -382,9 +390,13 @@ class TestSystemVirtualMemory(unittest.TestCase):
orig_open = open
patch_point = 'builtins.open' if PY3 else '__builtin__.open'
with mock.patch(patch_point, create=True, side_effect=open_mock) as m:
- ret = psutil.virtual_memory()
+ with warnings.catch_warnings(record=True) as ws:
+ ret = psutil.virtual_memory()
assert m.called
self.assertEqual(ret.available, 2057400 * 1024 + 4818144 * 1024)
+ w = ws[0]
+ self.assertIn(
+ "inactive memory stats couldn't be determined", str(w.message))
# =====================================================================
@@ -986,7 +998,7 @@ class TestMisc(unittest.TestCase):
patch_point = 'builtins.open' if PY3 else '__builtin__.open'
with mock.patch(patch_point, side_effect=open_mock):
- importlib.reload(psutil)
+ reload_module(psutil)
assert tb.called
self.assertRaises(IOError, psutil.cpu_times)
@@ -1025,7 +1037,7 @@ class TestMisc(unittest.TestCase):
sum(map(sum, psutil.cpu_times_percent(percpu=True))), 0)
finally:
shutil.rmtree(my_procfs)
- importlib.reload(psutil)
+ reload_module(psutil)
self.assertEqual(psutil.PROCFS_PATH, '/proc')