Path should handle malformed paths gracefully. Paths with leading slashes are not visible. Paths with dots are treated like regular files.
(self)
| 606 | alpharep.getinfo('does-not-exist') |
| 607 | |
| 608 | def test_malformed_paths(self): |
| 609 | """ |
| 610 | Path should handle malformed paths gracefully. |
| 611 | |
| 612 | Paths with leading slashes are not visible. |
| 613 | |
| 614 | Paths with dots are treated like regular files. |
| 615 | """ |
| 616 | data = io.BytesIO() |
| 617 | zf = zipfile.ZipFile(data, "w") |
| 618 | zf.writestr("/one-slash.txt", b"content") |
| 619 | zf.writestr("//two-slash.txt", b"content") |
| 620 | zf.writestr("../parent.txt", b"content") |
| 621 | zf.filename = '' |
| 622 | root = zipfile.Path(zf) |
| 623 | assert list(map(str, root.iterdir())) == ['../'] |
| 624 | assert root.joinpath('..').joinpath('parent.txt').read_bytes() == b'content' |
| 625 | |
| 626 | def test_unsupported_names(self): |
| 627 | """ |