003 File Manager
Current Path:
/usr/local/lib/python3.8/test/test_importlib
usr
/
local
/
lib
/
python3.8
/
test
/
test_importlib
/
📁
..
📄
__init__.py
(142 B)
📄
__main__.py
(58 B)
📁
__pycache__
📄
abc.py
(2.22 KB)
📁
builtin
📁
data
📁
data01
📁
data02
📁
data03
📁
extension
📄
fixtures.py
(4.99 KB)
📁
frozen
📁
import_
📁
namespace_pkgs
📁
source
📄
stubs.py
(233 B)
📄
test_abc.py
(33.07 KB)
📄
test_api.py
(18.36 KB)
📄
test_lazy.py
(4.81 KB)
📄
test_locks.py
(4.55 KB)
📄
test_main.py
(7.66 KB)
📄
test_metadata_api.py
(5.01 KB)
📄
test_namespace_pkgs.py
(10.57 KB)
📄
test_open.py
(2.2 KB)
📄
test_path.py
(1.53 KB)
📄
test_read.py
(1.99 KB)
📄
test_resource.py
(8.36 KB)
📄
test_spec.py
(30.38 KB)
📄
test_util.py
(34.67 KB)
📄
test_windows.py
(5.83 KB)
📄
test_zip.py
(2.41 KB)
📄
util.py
(18.04 KB)
📁
zipdata01
📁
zipdata02
Editing: test_path.py
import io import unittest from importlib import resources from . import data01 from . import util class CommonTests(util.CommonResourceTests, unittest.TestCase): def execute(self, package, path): with resources.path(package, path): pass class PathTests: def test_reading(self): # Path should be readable. # Test also implicitly verifies the returned object is a pathlib.Path # instance. with resources.path(self.data, 'utf-8.file') as path: # pathlib.Path.read_text() was introduced in Python 3.5. with path.open('r', encoding='utf-8') as file: text = file.read() self.assertEqual('Hello, UTF-8 world!\n', text) class PathDiskTests(PathTests, unittest.TestCase): data = data01 class PathMemoryTests(PathTests, unittest.TestCase): def setUp(self): file = io.BytesIO(b'Hello, UTF-8 world!\n') self.addCleanup(file.close) self.data = util.create_package( file=file, path=FileNotFoundError("package exists only in memory") ) self.data.__spec__.origin = None self.data.__spec__.has_location = False class PathZipTests(PathTests, util.ZipSetup, unittest.TestCase): def test_remove_in_context_manager(self): # It is not an error if the file that was temporarily stashed on the # file system is removed inside the `with` stanza. with resources.path(self.data, 'utf-8.file') as path: path.unlink() if __name__ == '__main__': unittest.main()
Upload File
Create Folder