When comparing text generated on different platforms, the newlines are different. This recipe normalizes any string to use unix-style newlines.
This code is used in the TestOOB unit testing framework (http://testoob.sourceforge.net).
1 2 3
def _normalize_newlines(string): import re return re.sub(r'(\r\n|\r|\n)', '\n', string)
I've tested this on POSIX and Windows. Anyone with an old Mac care to try it? :-)