name = 'foo?two=two&three=three', expected_result = False
@pytest.mark.parametrize(
"name,expected_result",
[(f"one.{ext}", True) for ext in TARBALL_EXTENSIONS]
+ [(f"one.{ext}?foo=bar", True) for ext in TARBALL_EXTENSIONS]
+ [(f"one?p0=1&foo=bar.{ext}", True) for ext in DEFAULT_EXTENSIONS_TO_IGNORE]
+ [("two?file=something.el", False), ("foo?two=two&three=three", False)],
)
def test_url_endswith(name, expected_result):
urlparsed = urlparse(f"https://example.org/{name}")
> assert url_endswith(urlparsed, TARBALL_EXTENSIONS) is expected_result
.tox/py3/lib/python3.7/site-packages/swh/lister/nixguix/tests/test_lister.py:58:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
urlparsed = ParseResult(scheme='https', netloc='example.org', path='/foo', params='', query='two=two&three=three', fragment='')
extensions = ['crate', 'gem', 'jar', 'love', 'zip', 'tar', ...]
raise_when_no_extension = True
def url_endswith(
urlparsed, extensions: List[str], raise_when_no_extension: bool = True
) -> bool:
"""Determine whether urlparsed ends with one of the extensions.
Raises:
ArtifactWithoutExtension in case no extension is available and raise_when_no_extension
is True (the default)
"""
paths = [Path(p) for (_, p) in [("_", urlparsed.path)] + parse_qsl(urlparsed.query)]
if raise_when_no_extension and not any(path.suffix != "" for path in paths):
> raise ArtifactWithoutExtension
E swh.lister.nixguix.lister.ArtifactWithoutExtension
.tox/py3/lib/python3.7/site-packages/swh/lister/nixguix/lister.py:154: ArtifactWithoutExtension
TEST RESULT
TEST RESULT
- Run At
- Oct 25 2022, 11:47 AM