Skip to content

Commit

Permalink
refact some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Jan 12, 2024
1 parent 20ba266 commit d4ae6a0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion psutil/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,8 @@ def wait_for_pid(pid):
"""Wait for pid to show up in the process list then return.
Used in the test suite to give time the sub process to initialize.
"""
if pid not in psutil.pids():
raise psutil.NoSuchProcess(pid)
psutil.Process(pid)
if WINDOWS:
# give it some more time to allow better initialization
Expand Down Expand Up @@ -950,7 +952,6 @@ class PsutilTestCase(TestCase):
"""

def get_testfn(self, suffix="", dir=None):
suffix += "-" + self.id() # add the test name
fname = get_testfn(suffix=suffix, dir=dir)
self.addCleanup(safe_rmpath, fname)
return fname
Expand Down
2 changes: 1 addition & 1 deletion psutil/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ def test_long_cmdline(self):
self.assertEqual(p.cmdline(), cmdline)

def test_name(self):
p = self.spawn_psproc(PYTHON_EXE)
p = self.spawn_psproc()
name = p.name().lower()
pyexe = os.path.basename(os.path.realpath(sys.executable)).lower()
assert pyexe.startswith(name), (pyexe, name)
Expand Down
4 changes: 1 addition & 3 deletions psutil/tests/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,7 @@ def test_proc_cmdline(self):
for part in cmdline:
self.assertIsInstance(part, str)
if self.expect_exact_path_match():
self.assertEqual(
cmdline, [self.funky_name, "-c", "time.sleep(10)"]
)
self.assertEqual(cmdline, cmd)

def test_proc_cwd(self):
dname = self.funky_name + "2"
Expand Down

0 comments on commit d4ae6a0

Please sign in to comment.