mirror of
https://github.com/python/cpython.git
synced 2025-07-31 15:14:22 +00:00

* bpo-45514: Apply changes from importlib_resources@a3ef4128c6 * Mark legacy functions as deprecated in the docs and link to the migration docs in importlib_resources docs. * Apply changes from importlib_resources@329ae9d5f2c. * Indicate importlib.resources as a module. Co-authored-by: Filipe Laíns <lains@riseup.net>
43 lines
967 B
Python
43 lines
967 B
Python
import unittest
|
|
from importlib import resources
|
|
|
|
from . import data01
|
|
from .resources import util
|
|
|
|
|
|
class ContentsTests:
|
|
expected = {
|
|
'__init__.py',
|
|
'binary.file',
|
|
'subdirectory',
|
|
'utf-16.file',
|
|
'utf-8.file',
|
|
}
|
|
|
|
def test_contents(self):
|
|
with util.suppress_known_deprecation():
|
|
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
|