Skip to content

Commit

Permalink
Test zip data for read()
Browse files Browse the repository at this point in the history
  • Loading branch information
brettcannon committed Oct 27, 2017
1 parent 6daf3d4 commit ca80944
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions importlib_resources/tests/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,26 @@ def execute(self, package, path):
resources.read(package, path)


class ReadTests(unittest.TestCase):
class ReadTests:

def test_default_encoding(self):
result = resources.read(data, 'utf-8.file')
result = resources.read(self.data, 'utf-8.file')
self.assertEqual("Hello, UTF-8 world!\n", result)

def test_encoding(self):
result = resources.read(data, 'utf-16.file', encoding='utf-16')
result = resources.read(self.data, 'utf-16.file', encoding='utf-16')
self.assertEqual("Hello, UTF-16 world!\n", result)

def test_errors(self):
# Raises UnicodeError without the 'errors' argument.
result = resources.read(data, 'utf-16.file', encoding='utf-8',
result = resources.read(self.data, 'utf-16.file', encoding='utf-8',
errors='ignore')


class ReadDiskTests(ReadTests, unittest.TestCase):

data = data


class ReadZipTests(ReadTests, util.ZipSetup, unittest.TestCase):
pass

0 comments on commit ca80944

Please sign in to comment.