bzr-0.1-rc1: selftest bugs (windows-specific): problem with line endings
Alexander Belchenko
bialix at ukr.net
Sun Oct 9 21:30:26 BST 2005
This bug in selftest appears very often so I think it needs to choose
appropriate strategy for preventing him. Some test check contents of
written text files by comparing him with string. But if text file
contains newline symbol it cause a problem on Windows (native and
Cygwin). Because on Windows (and for some case on Cygwin) line separator
is '\r\n'. Although Cygwin os.linesep is '\n' in reality when writing
text files it use '\r\n' for linesep (this moment has been discussed
earlier).
As result of windows linesep tests like this will always fails:
Traceback (most recent call last):
File "E:\work\Python\bzr\0.1\bzrlib\selftest\testinv.py", line 262,
in test_snapshot_new_revision
self.assertEqual(lines, ['contents of subdir/file\n'])
AssertionError: ['contents of subdir/file\r\n'] != ['contents of
subdir/file\n']
I think there is three ways to solve this:
1. Do not using of linesep when creating simple test files;
2. Using mode 'rU' when reading such files;
3. Creating text files for testing always in binary mode (i.e. with 'wb'
file mode).
May be there is another way to solve this, but I think ways mentioned
above is most simplest and does not requires deep rewriting of selftest
cases.
I think variant 3 (with writing all text files for tests in binary mode)
is most favorable, simple and correct.
Alexander
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.log
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20051009/48ab3e8b/attachment.diff
More information about the bazaar
mailing list