Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9575843

Browse files
committed
Fix mocking
1 parent 4d3cbdd commit 9575843

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Lib/test/test_subprocess.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1805,7 +1805,7 @@ class PopenNoDestructor(subprocess.Popen):
18051805
def __del__(self):
18061806
pass
18071807

1808-
@mock.patch("subprocess._posixsubprocess.fork_exec")
1808+
@mock.patch("subprocess._fork_exec")
18091809
def test_exception_errpipe_normal(self, fork_exec):
18101810
"""Test error passing done through errpipe_write in the good case"""
18111811
def proper_error(*args):
@@ -1822,7 +1822,7 @@ def proper_error(*args):
18221822
with self.assertRaises(IsADirectoryError):
18231823
self.PopenNoDestructor(["non_existent_command"])
18241824

1825-
@mock.patch("subprocess._posixsubprocess.fork_exec")
1825+
@mock.patch("subprocess._fork_exec")
18261826
def test_exception_errpipe_bad_data(self, fork_exec):
18271827
"""Test error passing done through errpipe_write where its not
18281828
in the expected format"""
@@ -2112,7 +2112,7 @@ def raise_it():
21122112
preexec_fn=raise_it)
21132113
except subprocess.SubprocessError as e:
21142114
self.assertTrue(
2115-
subprocess._posixsubprocess,
2115+
subprocess._fork_exec,
21162116
"Expected a ValueError from the preexec_fn")
21172117
except ValueError as e:
21182118
self.assertIn("coconut", e.args[0])
@@ -2600,11 +2600,11 @@ def prepare():
26002600
preexec_fn=prepare)
26012601
except ValueError as err:
26022602
# Pure Python implementations keeps the message
2603-
self.assertIsNone(subprocess._posixsubprocess)
2603+
self.assertIsNone(subprocess._fork_exec)
26042604
self.assertEqual(str(err), "surrogate:\uDCff")
26052605
except subprocess.SubprocessError as err:
26062606
# _posixsubprocess uses a default message
2607-
self.assertIsNotNone(subprocess._posixsubprocess)
2607+
self.assertIsNotNone(subprocess._fork_exec)
26082608
self.assertEqual(str(err), "Exception occurred in preexec_fn.")
26092609
else:
26102610
self.fail("Expected ValueError or subprocess.SubprocessError")

0 commit comments

Comments
 (0)