MCPcopy Index your code
hub / github.com/python/cpython / test_unsupported_names

Method test_unsupported_names

Lib/test/test_zipfile/_path/test_path.py:626–643  ·  view source on GitHub ↗

Path segments with special characters are readable. On some platforms or file systems, characters like ``:`` and ``?`` are not allowed, but they are valid in the zip file.

(self)

Source from the content-addressed store, hash-verified

624 assert root.joinpath('..').joinpath('parent.txt').read_bytes() == b'content'
625
626 def test_unsupported_names(self):
627 """
628 Path segments with special characters are readable.
629
630 On some platforms or file systems, characters like
631 ``:`` and ``?`` are not allowed, but they are valid
632 in the zip file.
633 """
634 data = io.BytesIO()
635 zf = zipfile.ZipFile(data, "w")
636 zf.writestr("path?", b"content")
637 zf.writestr("V: NMS.flac", b"fLaC...")
638 zf.filename = ''
639 root = zipfile.Path(zf)
640 contents = root.iterdir()
641 assert next(contents).name == 'path?'
642 assert next(contents).name == 'V: NMS.flac'
643 assert root.joinpath('V: NMS.flac').read_bytes() == b"fLaC..."
644
645 def test_backslash_not_separator(self):
646 """

Callers

nothing calls this directly

Calls 4

writestrMethod · 0.95
iterdirMethod · 0.95
joinpathMethod · 0.95
read_bytesMethod · 0.45

Tested by

no test coverage detected