Skip to content

gh-124212 fix invalid variable name in test_venv.py #124211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Lib/test/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,21 @@ def test_unicode_in_batch_file(self):
)
self.assertEqual(out.strip(), '0')

@unittest.skipUnless(os.name == 'nt' and can_symlink(),
'symlinks on Windows')
def test_failed_symlink(self):
"""
Test handling of failed symlinks on Windows.
"""
rmtree(self.env_dir)
env_dir = os.path.join(os.path.realpath(self.env_dir), 'venv')
with patch('os.symlink') as mock_symlink:
mock_symlink.side_effect = OSError()
builder = venv.EnvBuilder(clear=True, symlinks=True)
_, err = self.run_with_capture(builder.create, env_dir)
filepath_regex = r"'[A-Z]:\\\\(?:[^\\\\]+\\\\)*[^\\\\]+'"
self.assertRegex(err, rf"Unable to symlink {filepath_regex} to {filepath_regex}")

@requireVenvCreate
def test_multiprocessing(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion Lib/venv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def setup_python(self, context):
os.symlink(src, dest)
to_unlink.append(dest)
except OSError:
logger.warning('Unable to symlink %r to %r', src, dst)
logger.warning('Unable to symlink %r to %r', src, dest)
do_copies = True
for f in to_unlink:
try:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix invalid variable in :mod:`venv` handling of failed symlink on Windows
Loading