summaryrefslogtreecommitdiff
path: root/psutil/tests
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2020-01-31 16:14:39 -0800
committerGiampaolo Rodola <g.rodola@gmail.com>2020-01-31 16:14:39 -0800
commit87ef286a05fc9502d8d6ac461827c33b6d31455b (patch)
tree3a6a3ce271aadafde987e9cc0628ba2de6bf2afb /psutil/tests
parent607a8a831935b38e2625e749761aec2e530df764 (diff)
downloadpsutil-87ef286a05fc9502d8d6ac461827c33b6d31455b.tar.gz
remove proc_name()
Diffstat (limited to 'psutil/tests')
-rwxr-xr-xpsutil/tests/test_process.py3
-rwxr-xr-xpsutil/tests/test_unicode.py24
-rwxr-xr-xpsutil/tests/test_windows.py24
3 files changed, 4 insertions, 47 deletions
diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py
index 0b54f5b1..96dc6788 100755
--- a/psutil/tests/test_process.py
+++ b/psutil/tests/test_process.py
@@ -1325,6 +1325,9 @@ class TestProcess(unittest.TestCase):
except NotImplementedError:
pass
else:
+ # NtQuerySystemInformation caches result.
+ if WINDOWS and name in ('exe', 'name'):
+ continue
self.fail(
"NoSuchProcess exception not raised for %r, retval=%s" % (
name, ret))
diff --git a/psutil/tests/test_unicode.py b/psutil/tests/test_unicode.py
index 6b1d720e..a6eb113c 100755
--- a/psutil/tests/test_unicode.py
+++ b/psutil/tests/test_unicode.py
@@ -171,16 +171,7 @@ class _BaseFSAPIsTests(object):
def test_proc_name(self):
subp = get_test_subprocess(cmd=[self.funky_name])
- if WINDOWS:
- # On Windows name() is determined from exe() first, because
- # it's faster; we want to overcome the internal optimization
- # and test name() instead of exe().
- with mock.patch("psutil._psplatform.cext.proc_exe",
- side_effect=psutil.AccessDenied(os.getpid())) as m:
- name = psutil.Process(subp.pid).name()
- assert m.called
- else:
- name = psutil.Process(subp.pid).name()
+ name = psutil.Process(subp.pid).name()
self.assertIsInstance(name, str)
if self.expect_exact_path_match():
self.assertEqual(name, os.path.basename(self.funky_name))
@@ -321,19 +312,6 @@ class TestFSAPIsWithInvalidPath(_BaseFSAPIsTests, unittest.TestCase):
return True
-@unittest.skipIf(not WINDOWS, "WINDOWS only")
-class TestWinProcessName(unittest.TestCase):
-
- def test_name_type(self):
- # On Windows name() is determined from exe() first, because
- # it's faster; we want to overcome the internal optimization
- # and test name() instead of exe().
- with mock.patch("psutil._psplatform.cext.proc_exe",
- side_effect=psutil.AccessDenied(os.getpid())) as m:
- self.assertIsInstance(psutil.Process().name(), str)
- assert m.called
-
-
# ===================================================================
# Non fs APIs
# ===================================================================
diff --git a/psutil/tests/test_windows.py b/psutil/tests/test_windows.py
index de41aed8..61cf14bf 100755
--- a/psutil/tests/test_windows.py
+++ b/psutil/tests/test_windows.py
@@ -326,20 +326,6 @@ class TestProcess(unittest.TestCase):
p = psutil.Process(self.pid)
self.assertRaises(ValueError, p.send_signal, signal.SIGINT)
- def test_exe_and_name(self):
- for p in psutil.process_iter():
- # On Windows name() is never supposed to raise AccessDenied,
- # see https://github.com/giampaolo/psutil/issues/627
- try:
- name = p.name()
- except psutil.NoSuchProcess:
- pass
- else:
- try:
- self.assertEqual(os.path.basename(p.exe()), name)
- except psutil.Error:
- continue
-
def test_num_handles_increment(self):
p = psutil.Process(os.getpid())
before = p.num_handles()
@@ -610,16 +596,6 @@ class TestDualProcessImplementation(unittest.TestCase):
@classmethod
def tearDownClass(cls):
reap_children()
- # ---
- # same tests as above but mimicks the AccessDenied failure of
- # the first (fast) method failing with AD.
-
- def test_name(self):
- name = psutil.Process(self.pid).name()
- with mock.patch("psutil._psplatform.cext.proc_exe",
- side_effect=psutil.AccessDenied(os.getpid())) as fun:
- self.assertEqual(psutil.Process(self.pid).name(), name)
- assert fun.called
def test_memory_info(self):
mem_1 = psutil.Process(self.pid).memory_info()