diff --git a/pyproject.toml b/pyproject.toml index 874996b..db9823d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,6 @@ test = [ "pytest-ignore-flaky", "jaraco.test", "importlib_resources; python_version < '3.9'", - "pytest-timeout", ] doc = [ diff --git a/tests/test_path.py b/tests/test_path.py index 4571c00..4884587 100644 --- a/tests/test_path.py +++ b/tests/test_path.py @@ -586,7 +586,6 @@ def test_getinfo_missing(self, alpharep): alpharep.getinfo('does-not-exist') @pytest.mark.xfail(reason="python/cpython#123270") - @pytest.mark.timeout(1) def test_malformed_paths(self): """ Path should handle malformed paths. diff --git a/zipp/__init__.py b/zipp/__init__.py index 051bfc9..0b7b443 100644 --- a/zipp/__init__.py +++ b/zipp/__init__.py @@ -46,7 +46,7 @@ def _parents(path): def _ancestry(path): """ Given a path with elements separated by - posixpath.sep, generate all elements of that path + posixpath.sep, generate all elements of that path. >>> list(_ancestry('b/d')) ['b/d', 'b'] @@ -58,9 +58,14 @@ def _ancestry(path): ['b'] >>> list(_ancestry('')) [] + + Multiple separators are treated like a single. + + >>> list(_ancestry('//b//d///f//')) + ['//b//d///f', '//b//d', '//b'] """ path = path.rstrip(posixpath.sep) - while path and path != posixpath.sep: + while path and not path.endswith(posixpath.sep): yield path path, tail = posixpath.split(path)