-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #220 from FFY00/test-contents
tests: add test for contents()
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import unittest | ||
import importlib_resources as resources | ||
|
||
from . import data01 | ||
from . import util | ||
|
||
|
||
class ContentsTests: | ||
expected = { | ||
'__init__.py', | ||
'binary.file', | ||
'subdirectory', | ||
'utf-16.file', | ||
'utf-8.file', | ||
} | ||
|
||
def test_contents(self): | ||
assert self.expected <= set(resources.contents(self.data)) | ||
|
||
|
||
class ContentsDiskTests(ContentsTests, unittest.TestCase): | ||
def setUp(self): | ||
self.data = data01 | ||
|
||
|
||
class ContentsZipTests(ContentsTests, util.ZipSetup, unittest.TestCase): | ||
pass | ||
|
||
|
||
class ContentsNamespaceTests(ContentsTests, unittest.TestCase): | ||
expected = { | ||
# no __init__ because of namespace design | ||
# no subdirectory as incidental difference in fixture | ||
'binary.file', | ||
'utf-16.file', | ||
'utf-8.file', | ||
} | ||
|
||
def setUp(self): | ||
from . import namespacedata01 | ||
|
||
self.data = namespacedata01 |