Skip to content

Commit

Permalink
bpo-35661: Store the venv prompt in pyvenv.cfg (pythonGH-11440)
Browse files Browse the repository at this point in the history
  • Loading branch information
csabella committed Mar 8, 2019
1 parent 2aab5d3 commit d5a70c6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Lib/test/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,16 @@ def test_prompt(self):
builder = venv.EnvBuilder()
context = builder.ensure_directories(self.env_dir)
self.assertEqual(context.prompt, '(%s) ' % env_name)
builder.create(self.env_dir)
data = self.get_text_file_contents('pyvenv.cfg')
self.assertNotIn("prompt = ", data)

builder = venv.EnvBuilder(prompt='My prompt')
context = builder.ensure_directories(self.env_dir)
self.assertEqual(context.prompt, '(My prompt) ')
builder.create(self.env_dir)
data = self.get_text_file_contents('pyvenv.cfg')
self.assertIn("prompt = 'My prompt'\n", data)

@skipInVenv
def test_prefixes(self):
Expand Down
2 changes: 2 additions & 0 deletions Lib/venv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ def create_configuration(self, context):
incl = 'false'
f.write('include-system-site-packages = %s\n' % incl)
f.write('version = %d.%d.%d\n' % sys.version_info[:3])
if self.prompt is not None:
f.write(f'prompt = {self.prompt!r}\n')

def symlink_or_copy(self, src, dst, relative_symlinks_ok=False):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Store the venv prompt in pyvenv.cfg.

0 comments on commit d5a70c6

Please sign in to comment.