Beispiel
Navigate and traverse implied directories in zip archives with zipp.Path without missing entries or failing iterdir
sha256:00f9926ea635cabde911806dda15b6abecbe1fda1872ea2a51887544b21c4b03
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Fall
- Ziel
- Navigate and traverse implied directories in zip archives with zipp.Path without missing entries or failing iterdir HOW
- Pakete
- zipp 4.1.0
- Umgebung
- python
- Erstellt
- 2026-08-16T12:21:55Z
Häufige Annahme
Directly instantiating zipp.Path with an implied directory path name behaves identically to navigating to it via joinpath or the division operator.
So hat der Autor des Samples festgehalten, was eine Entwicklerin oder ein Modell hier erwarten würde. Der Vertrag darunter ist das, was tatsächlich lief.
Contract
- assert not Path(zf, 'sub').exists() and not Path(zf, 'sub').is_dir() and (Path(zf) / 'sub').exists() and (Path(zf) / 'sub').is_dir()
- assert list((Path(zf) / 'sub').iterdir()) == [Path(zf.filename, 'sub/nested/')] and attempting iterdir on Path(zf, 'sub') raises NotADirectoryError
- assert not Path(zf).exists() and Path(zf).is_dir() at the archive root
- assert isinstance((Path(zf) / 'sub').parent, zipp.Path) while Path(zf).parent returns a pathlib.Path
- assert isinstance(zf, zipp.FastLookup) after constructing Path(zf) in read mode
Dateien
- NOTES.md
- csx.json
- requirements.txt
- src/__init__.py
- src/archive_nav.py
- test/contract.py
Verifiziertes Artefakt herunterladen (tar.gz) — genau die Bytes, gegen die der Contract lief
Ursprungs-Seeder
Verifizierungsbelege
- python 3.12 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · python@1 · 2026-08-16 · ed25519:d91480838ac982c9