gh-119064: Use os_helper.FakePath instead of pathlib.Path in tests (GH-119065)

This commit is contained in:
Serhiy Storchaka 2024-05-16 10:25:10 +03:00 committed by GitHub
parent 0142a2292c
commit 0152dc4ff5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 115 additions and 127 deletions

View file

@ -25,7 +25,6 @@ import threading
import gc
import textwrap
import json
import pathlib
from test.support.os_helper import FakePath
try:
@ -1522,9 +1521,6 @@ class ProcessTestCase(BaseTestCase):
p.communicate(b"x" * 2**20)
def test_repr(self):
path_cmd = pathlib.Path("my-tool.py")
pathlib_cls = path_cmd.__class__.__name__
cases = [
("ls", True, 123, "<Popen: returncode: 123 args: 'ls'>"),
('a' * 100, True, 0,
@ -1532,7 +1528,8 @@ class ProcessTestCase(BaseTestCase):
(["ls"], False, None, "<Popen: returncode: None args: ['ls']>"),
(["ls", '--my-opts', 'a' * 100], False, None,
"<Popen: returncode: None args: ['ls', '--my-opts', 'aaaaaaaaaaaaaaaaaaaaaaaa...>"),
(path_cmd, False, 7, f"<Popen: returncode: 7 args: {pathlib_cls}('my-tool.py')>")
(os_helper.FakePath("my-tool.py"), False, 7,
"<Popen: returncode: 7 args: <FakePath 'my-tool.py'>>")
]
with unittest.mock.patch.object(subprocess.Popen, '_execute_child'):
for cmd, shell, code, sx in cases: