Message333435
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. |
|
Date |
User |
Action |
Args |
2019-01-11 04:39:56 | steve.dower | set | recipients:
+ steve.dower, brett.cannon, vinay.sajip, cheryl.sabella |
2019-01-11 04:39:54 | steve.dower | set | messageid: <1547181594.26.0.447414383097.issue35661@roundup.psfhosted.org> |
2019-01-11 04:39:54 | steve.dower | link | issue35661 messages |
2019-01-11 04:39:54 | steve.dower | create | |
|