Steve Dower <[email protected]> added the comment:
Your tests actually went the other way. This one puts a trailing space after
the prompt and expected it to be there in the file, but also ensured that
exactly one space was added at the start.
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)
In the line "prompt = (My prompt) ", we need to define which of the spaces at
either end of the value should be retained by tools trying to use the same
prompt. The obvious assumption is to strip both ends, which would break your
test. The next most obvious is to quote the string value (e.g. write
repr(context.prompt) instead of the prompt directly).
Also, I'm pretty sure I saw some advice once to use multiple lines worth of
prompt, which probably breaks many shells but presumably works okay in Bash.
You'll need to handle that case as well - again, repr() will do it naturally by
encoding newlines an "\n".
Anyone reading the string will have to do the equivalent of Python's
literal_eval(), but that's pretty manageable in exchange for avoiding a whole
lot of edge cases.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35661>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com