OK -- all tests pass on Windows now. The rest were due to 3 more

binary-vs-text-mode screwups.
This commit is contained in:
Tim Peters 2002-11-09 06:49:43 +00:00
parent 9de06bd605
commit 63c1081ae3
1 changed files with 5 additions and 22 deletions

View File

@ -33,22 +33,9 @@ class BaseTest(unittest.TestCase):
else: else:
# popen2.Popen3 doesn't exist on Windows, and even if it did, bunzip2 # popen2.Popen3 doesn't exist on Windows, and even if it did, bunzip2
# isn't available to run. # isn't available to run.
# XXX This alternative doesn't work in all tests. It raises
# XXX ValueError: couldn't find end of stream
# XXX in
# XXX testWrite
# XXX testWriteChunks10
# XXX testWriteLines
# XXX from BZ2FileTest .
# XXX I don't know why.
def decompress(self, data): def decompress(self, data):
return bz2.decompress(data) return bz2.decompress(data)
# XXX See XXX comment above.
skip_mystery_test = not has_cmdline_bunzip2
class BZ2FileTest(BaseTest): class BZ2FileTest(BaseTest):
"Test MCRYPT type miscelaneous methods." "Test MCRYPT type miscelaneous methods."
@ -145,20 +132,18 @@ class BZ2FileTest(BaseTest):
bz2f.close() bz2f.close()
def testWrite(self): def testWrite(self):
if self.skip_mystery_test: #if self.skip_mystery_test:
return # return
# "Test BZ2File.write()" # "Test BZ2File.write()"
bz2f = BZ2File(self.filename, "w") bz2f = BZ2File(self.filename, "w")
bz2f.write(self.TEXT) bz2f.write(self.TEXT)
bz2f.close() bz2f.close()
f = open(self.filename) f = open(self.filename, 'rb')
self.assertEqual(self.decompress(f.read()), self.TEXT) self.assertEqual(self.decompress(f.read()), self.TEXT)
f.close() f.close()
def testWriteChunks10(self): def testWriteChunks10(self):
# "Test BZ2File.write() with chunks of 10 bytes" # "Test BZ2File.write() with chunks of 10 bytes"
if self.skip_mystery_test:
return
bz2f = BZ2File(self.filename, "w") bz2f = BZ2File(self.filename, "w")
n = 0 n = 0
while 1: while 1:
@ -168,19 +153,17 @@ class BZ2FileTest(BaseTest):
bz2f.write(str) bz2f.write(str)
n += 1 n += 1
bz2f.close() bz2f.close()
f = open(self.filename) f = open(self.filename, 'rb')
self.assertEqual(self.decompress(f.read()), self.TEXT) self.assertEqual(self.decompress(f.read()), self.TEXT)
f.close() f.close()
def testWriteLines(self): def testWriteLines(self):
# "Test BZ2File.writelines()" # "Test BZ2File.writelines()"
if self.skip_mystery_test:
return
bz2f = BZ2File(self.filename, "w") bz2f = BZ2File(self.filename, "w")
sio = StringIO(self.TEXT) sio = StringIO(self.TEXT)
bz2f.writelines(sio.readlines()) bz2f.writelines(sio.readlines())
bz2f.close() bz2f.close()
f = open(self.filename) f = open(self.filename, 'rb')
self.assertEqual(self.decompress(f.read()), self.TEXT) self.assertEqual(self.decompress(f.read()), self.TEXT)
f.close() f.close()