Skip to content

Uncomment broken fileio tests but mark them skipped for diff reduction. #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 63 additions & 72 deletions tests/test_mig_shared_fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,16 @@
import binascii
import os
import sys

# TODO: remove this as it should not be needed with PYTHONPATH properly set
#sys.path.append(os.path.realpath(os.path.join(os.path.dirname(__file__), ".")))
import unittest

# NOTE: wrap next imports in try except to prevent autopep8 shuffling up
try:
from tests.support import MigTestCase, cleanpath, temppath, testmain
import mig.shared.fileio as fileio
except ImportError as ioe:
print("Failed to import mig core modules: %s" % ioe)
exit(1)

# NOTE: prevent autopep8 shuffling next imports up
try:
from support import MigTestCase, cleanpath, temppath, testmain
except ImportError as ioe:
print("Failed to import mig test modules: %s" % ioe)
exit(1)


DUMMY_BYTES = binascii.unhexlify('DEADBEEF') # 4 bytes
DUMMY_BYTES_LENGTH = 4
DUMMY_UNICODE = u'UniCode123½¾µßðþđŋħĸþł@ª€£$¥©®'
Expand Down Expand Up @@ -106,35 +97,35 @@ def test_store_bytes_at_offset(self):
"expected a hole was left")
self.assertEqual(content[3:], DUMMY_BYTES)

# TODO: enable again - requires the temporarily disabled auto mode select
# def test_store_bytes_in_text_mode(self):
# fileio.write_chunk(self.tmp_path, DUMMY_BYTES, 0, self.logger,
# mode="r+")
#
# with open(self.tmp_path, 'rb') as file:
# content = file.read(1024)
# self.assertEqual(len(content), DUMMY_BYTES_LENGTH)
# self.assertEqual(content[:], DUMMY_BYTES)

# TODO: enable again - requires the temporarily disabled auto mode select
# def test_store_unicode(self):
# fileio.write_chunk(self.tmp_path, DUMMY_UNICODE, 0, self.logger,
# mode='r+')
#
# with open(self.tmp_path, 'r') as file:
# content = file.read(1024)
# self.assertEqual(len(content), DUMMY_UNICODE_LENGTH)
# self.assertEqual(content[:], DUMMY_UNICODE)

# TODO: enable again - requires the temporarily disabled auto mode select
# def test_store_unicode_in_binary_mode(self):
# fileio.write_chunk(self.tmp_path, DUMMY_UNICODE, 0, self.logger,
# mode='r+b')
#
# with open(self.tmp_path, 'r') as file:
# content = file.read(1024)
# self.assertEqual(len(content), DUMMY_UNICODE_LENGTH)
# self.assertEqual(content[:], DUMMY_UNICODE)
@unittest.skip("TODO: enable again - requires the temporarily disabled auto mode select")
def test_store_bytes_in_text_mode(self):
fileio.write_chunk(self.tmp_path, DUMMY_BYTES, 0, self.logger,
mode="r+")

with open(self.tmp_path, 'rb') as file:
content = file.read(1024)
self.assertEqual(len(content), DUMMY_BYTES_LENGTH)
self.assertEqual(content[:], DUMMY_BYTES)

@unittest.skip("TODO: enable again - requires the temporarily disabled auto mode select")
def test_store_unicode(self):
fileio.write_chunk(self.tmp_path, DUMMY_UNICODE, 0, self.logger,
mode='r+')

with open(self.tmp_path, 'r') as file:
content = file.read(1024)
self.assertEqual(len(content), DUMMY_UNICODE_LENGTH)
self.assertEqual(content[:], DUMMY_UNICODE)

@unittest.skip("TODO: enable again - requires the temporarily disabled auto mode select")
def test_store_unicode_in_binary_mode(self):
fileio.write_chunk(self.tmp_path, DUMMY_UNICODE, 0, self.logger,
mode='r+b')

with open(self.tmp_path, 'r') as file:
content = file.read(1024)
self.assertEqual(len(content), DUMMY_UNICODE_LENGTH)
self.assertEqual(content[:], DUMMY_UNICODE)


class MigSharedFileio__write_file(MigTestCase):
Expand Down Expand Up @@ -180,38 +171,38 @@ def test_store_bytes(self):
self.assertEqual(len(content), DUMMY_BYTES_LENGTH)
self.assertEqual(content[:], DUMMY_BYTES)

# TODO: enable again - requires the temporarily disabled auto mode select
# def test_store_bytes_in_text_mode(self):
# did_succeed = fileio.write_file(DUMMY_BYTES, self.tmp_path, self.logger,
# mode="w")
# self.assertTrue(did_succeed)
#
# with open(self.tmp_path, 'rb') as file:
# content = file.read(1024)
# self.assertEqual(len(content), DUMMY_BYTES_LENGTH)
# self.assertEqual(content[:], DUMMY_BYTES)

# TODO: enable again - requires the temporarily disabled auto mode select
# def test_store_unicode(self):
# did_succeed = fileio.write_file(DUMMY_UNICODE, self.tmp_path,
# self.logger, mode='w')
# self.assertTrue(did_succeed)
#
# with open(self.tmp_path, 'r') as file:
# content = file.read(1024)
# self.assertEqual(len(content), DUMMY_UNICODE_LENGTH)
# self.assertEqual(content[:], DUMMY_UNICODE)

# TODO: enable again - requires the temporarily disabled auto mode select
# def test_store_unicode_in_binary_mode(self):
# did_succeed = fileio.write_file(DUMMY_UNICODE, self.tmp_path,
# self.logger, mode='wb')
# self.assertTrue(did_succeed)
#
# with open(self.tmp_path, 'r') as file:
# content = file.read(1024)
# self.assertEqual(len(content), DUMMY_UNICODE_LENGTH)
# self.assertEqual(content[:], DUMMY_UNICODE)
@unittest.skip("TODO: enable again - requires the temporarily disabled auto mode select")
def test_store_bytes_in_text_mode(self):
did_succeed = fileio.write_file(DUMMY_BYTES, self.tmp_path, self.logger,
mode="w")
self.assertTrue(did_succeed)

with open(self.tmp_path, 'rb') as file:
content = file.read(1024)
self.assertEqual(len(content), DUMMY_BYTES_LENGTH)
self.assertEqual(content[:], DUMMY_BYTES)

@unittest.skip("TODO: enable again - requires the temporarily disabled auto mode select")
def test_store_unicode(self):
did_succeed = fileio.write_file(DUMMY_UNICODE, self.tmp_path,
self.logger, mode='w')
self.assertTrue(did_succeed)

with open(self.tmp_path, 'r') as file:
content = file.read(1024)
self.assertEqual(len(content), DUMMY_UNICODE_LENGTH)
self.assertEqual(content[:], DUMMY_UNICODE)

@unittest.skip("TODO: enable again - requires the temporarily disabled auto mode select")
def test_store_unicode_in_binary_mode(self):
did_succeed = fileio.write_file(DUMMY_UNICODE, self.tmp_path,
self.logger, mode='wb')
self.assertTrue(did_succeed)

with open(self.tmp_path, 'r') as file:
content = file.read(1024)
self.assertEqual(len(content), DUMMY_UNICODE_LENGTH)
self.assertEqual(content[:], DUMMY_UNICODE)


if __name__ == '__main__':
Expand Down