Skip to content

Commit

Permalink
hopefully make process tests more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Jan 7, 2024
1 parent b2444ab commit 4065dd5
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions psutil/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,9 +746,9 @@ def test_cmdline(self):

@unittest.skipIf(PYPY, "broken on PYPY")
def test_long_cmdline(self):
testfn = self.get_testfn()
create_exe(testfn)
cmdline = [testfn] + (["0123456789"] * 20)
cmdline = [PYTHON_EXE]
cmdline.extend(["-v"] * 50)
cmdline.extend(["-c", "time.sleep(10)"])
p = self.spawn_psproc(cmdline)
if OPENBSD:
# XXX: for some reason the test process may turn into a
Expand All @@ -770,7 +770,7 @@ def test_name(self):
def test_long_name(self):
testfn = self.get_testfn(suffix="0123456789" * 2)
create_exe(testfn)
cmdline = [testfn] + (["0123456789"] * 20)
cmdline = [testfn, "-c", "time.sleep(10)"]
p = self.spawn_psproc(cmdline)
if OPENBSD:
# XXX: for some reason the test process may turn into a
Expand Down Expand Up @@ -800,15 +800,7 @@ def test_prog_w_funky_name(self):
# https://github.com/giampaolo/psutil/issues/628
funky_path = self.get_testfn(suffix='foo bar )')
create_exe(funky_path)
cmdline = [
funky_path,
"-c",
"import time; [time.sleep(0.01) for x in range(3000)];arg1",
"arg2",
"",
"arg3",
"",
]
cmdline = [funky_path, "-c", "time.sleep(10)"]
p = self.spawn_psproc(cmdline)
self.assertEqual(p.cmdline(), cmdline)
self.assertEqual(p.name(), os.path.basename(funky_path))
Expand Down

0 comments on commit 4065dd5

Please sign in to comment.