From ca8094415e355c330170b2add29dd61e248342cd Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 27 Oct 2017 12:06:08 -0700 Subject: [PATCH] Test zip data for read() --- importlib_resources/tests/test_read.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/importlib_resources/tests/test_read.py b/importlib_resources/tests/test_read.py index 67f0d6a1..76791172 100644 --- a/importlib_resources/tests/test_read.py +++ b/importlib_resources/tests/test_read.py @@ -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