Code review comment for lp:~gagern/bzr/encodingSafeTests

Revision history for this message
Andrew Bennetts (spiv) wrote :

+ return string_or_unicode.encode('string_escape').replace(r'\n', '\n')

This mangles the output:

>>> x = r'backslash n, not newline: \n'
>>> x.encode('string_escape').replace(r'\n', '\n')
'backslash n, not newline: \\\n'
>>> '\n' in x
False
>>> '\n' in x.encode('string_escape').replace(r'\n', '\n')
True

Otherwise this seems ok. When UnicodeErrors occur you _safe_str all variable that might be involved, which is perhaps too zealous. But it's undoubtedly better than allowing the UnicodeError to abort selftest.

review: Needs Fixing

« Back to merge proposal