Skip to content

Commit d4ae6a0

Browse files
committed
refact some tests
1 parent 20ba266 commit d4ae6a0

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

psutil/tests/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,8 @@ def wait_for_pid(pid):
757757
"""Wait for pid to show up in the process list then return.
758758
Used in the test suite to give time the sub process to initialize.
759759
"""
760+
if pid not in psutil.pids():
761+
raise psutil.NoSuchProcess(pid)
760762
psutil.Process(pid)
761763
if WINDOWS:
762764
# give it some more time to allow better initialization
@@ -950,7 +952,6 @@ class PsutilTestCase(TestCase):
950952
"""
951953

952954
def get_testfn(self, suffix="", dir=None):
953-
suffix += "-" + self.id() # add the test name
954955
fname = get_testfn(suffix=suffix, dir=dir)
955956
self.addCleanup(safe_rmpath, fname)
956957
return fname

psutil/tests/test_process.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ def test_long_cmdline(self):
762762
self.assertEqual(p.cmdline(), cmdline)
763763

764764
def test_name(self):
765-
p = self.spawn_psproc(PYTHON_EXE)
765+
p = self.spawn_psproc()
766766
name = p.name().lower()
767767
pyexe = os.path.basename(os.path.realpath(sys.executable)).lower()
768768
assert pyexe.startswith(name), (pyexe, name)

psutil/tests/test_unicode.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,7 @@ def test_proc_cmdline(self):
224224
for part in cmdline:
225225
self.assertIsInstance(part, str)
226226
if self.expect_exact_path_match():
227-
self.assertEqual(
228-
cmdline, [self.funky_name, "-c", "time.sleep(10)"]
229-
)
227+
self.assertEqual(cmdline, cmd)
230228

231229
def test_proc_cwd(self):
232230
dname = self.funky_name + "2"

0 commit comments

Comments
 (0)