unittest BUG?

D-Man dsh8290 at rit.edu
Fri May 18 14:56:07 EDT 2001


On Fri, May 18, 2001 at 07:27:59PM +0100, Robin Becker wrote:
| We are using unittest.py $Revision: 1.3 $ and see extra ^Ms on
| win32. It seems the problem comes from using the os.linesep in the
| following when the stream is stdout. Is there a sensible
| way for this kind of class to obtain a sensible line terminator?
| Clearly the correct linesep for files opened in text mode is '\n'.

On M$ Windo~1 the proper line separator is '\r\n'.  What are you using
to view the output?  cmd.exe?  bash(cygwin)?  vim?  less? 

Note that if you use '\n' instead of '\r\n' Notepad will display a
black box instead of a newline character.  The lines will not wrap
properly (Notepad is broken).


Here are some examples from a Win2k box:

Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import os
>>> repr( os.linesep )
"'\\015\\012'"
>>>

Jython 2.0 on java1.3.0 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> import os
>>> repr( os.linesep )
"'\\r\\n'"
>>>

Python 2.1 (#1, Apr 17 2001, 09:45:01)
[GCC 2.95.3-2 (cygwin special)] on cygwin_nt-4.01
Type "copyright", "credits" or "license" for more information.
>>> import os
>>> repr( os.linesep )
"'\\n'"
>>>


I think the solution for you would either be to change the way you
view the files so you don't see the carriage returns or modify
os.linesep so that it is Unix-style and not windows-style.

HTH,
-D





More information about the Python-list mailing list