Commit d5a70c6b authored by Cheryl Sabella's avatar Cheryl Sabella Committed by GitHub

bpo-35661: Store the venv prompt in pyvenv.cfg (GH-11440)

parent 2aab5d31
...@@ -113,10 +113,16 @@ class BasicTest(BaseTest): ...@@ -113,10 +113,16 @@ class BasicTest(BaseTest):
builder = venv.EnvBuilder() builder = venv.EnvBuilder()
context = builder.ensure_directories(self.env_dir) context = builder.ensure_directories(self.env_dir)
self.assertEqual(context.prompt, '(%s) ' % env_name) 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') builder = venv.EnvBuilder(prompt='My prompt')
context = builder.ensure_directories(self.env_dir) context = builder.ensure_directories(self.env_dir)
self.assertEqual(context.prompt, '(My prompt) ') 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 @skipInVenv
def test_prefixes(self): def test_prefixes(self):
......
...@@ -154,6 +154,8 @@ class EnvBuilder: ...@@ -154,6 +154,8 @@ class EnvBuilder:
incl = 'false' incl = 'false'
f.write('include-system-site-packages = %s\n' % incl) f.write('include-system-site-packages = %s\n' % incl)
f.write('version = %d.%d.%d\n' % sys.version_info[:3]) 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): def symlink_or_copy(self, src, dst, relative_symlinks_ok=False):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment