summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-12-07 11:02:35 +0100
committerGitHub <noreply@github.com>2017-12-07 11:02:35 +0100
commitc3767da76a366cabbe1c84ad9cef007ae51c400e (patch)
tree44ae79e78d5e83b892811de8e37a432a044b653b
parent82c77dc888e8a44a4f86aecc387c30b42150eb7a (diff)
downloadpsutil-c3767da76a366cabbe1c84ad9cef007ae51c400e.tar.gz
Use FutureWarning instead of DeprecationWarning (#1188)
* make Process.memory_info_ex() raise FutureWarning instead of DeprecationWarning because the latter is suppressed by default * update HISTORY * add test case
-rw-r--r--HISTORY.rst2
-rw-r--r--psutil/_common.py4
-rwxr-xr-xpsutil/tests/test_contracts.py17
3 files changed, 21 insertions, 2 deletions
diff --git a/HISTORY.rst b/HISTORY.rst
index 7b8f7f41..a8bc3102 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -11,6 +11,8 @@
to print useful debug messages on stderr (useful in case of nasty errors).
- 1177_: added support for sensors_battery() on OSX. (patch by Arnon Yaari)
- 1183_: Process.children() is 2x faster on UNIX and 2.4x faster on Linux.
+- 1188_: deprecated method Process.memory_info_ex() now warns by using
+ FutureWarning instead of DeprecationWarning.
**Bug fixes**
diff --git a/psutil/_common.py b/psutil/_common.py
index 2d562f93..870971e4 100644
--- a/psutil/_common.py
+++ b/psutil/_common.py
@@ -461,14 +461,14 @@ def deprecated_method(replacement):
'replcement' is the method name which will be called instead.
"""
def outer(fun):
- msg = "%s() is deprecated; use %s() instead" % (
+ msg = "%s() is deprecated and will be removed; use %s() instead" % (
fun.__name__, replacement)
if fun.__doc__ is None:
fun.__doc__ = msg
@functools.wraps(fun)
def inner(self, *args, **kwargs):
- warnings.warn(msg, category=DeprecationWarning, stacklevel=2)
+ warnings.warn(msg, category=FutureWarning, stacklevel=2)
return getattr(self, replacement)(*args, **kwargs)
return inner
return outer
diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py
index 4c57b25a..855b53bf 100755
--- a/psutil/tests/test_contracts.py
+++ b/psutil/tests/test_contracts.py
@@ -14,6 +14,7 @@ import os
import stat
import time
import traceback
+import warnings
from contextlib import closing
from psutil import AIX
@@ -168,6 +169,22 @@ class TestAvailability(unittest.TestCase):
# ===================================================================
+# --- Test deprecations
+# ===================================================================
+
+
+class TestDeprecations(unittest.TestCase):
+
+ def test_memory_info_ex(self):
+ with warnings.catch_warnings(record=True) as ws:
+ psutil.Process().memory_info_ex()
+ w = ws[0]
+ self.assertIsInstance(w.category(), FutureWarning)
+ self.assertIn("memory_info_ex() is deprecated", str(w.message))
+ self.assertIn("use memory_info() instead", str(w.message))
+
+
+# ===================================================================
# --- System API types
# ===================================================================