Skip to content

Commit

Permalink
test: protocol not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
andreoliwa committed Jul 11, 2021
1 parent dcbfa7f commit d4b5a0a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/nitpick/style/fetchers/__init__.py
Expand Up @@ -43,7 +43,7 @@ def fetch(self, url) -> StyleInfo:
if not fetcher:
fetcher = self.fetchers.get(scheme)
if not fetcher:
raise RuntimeError(f"Protocol {scheme} and/or domain {domain} not supported")
raise RuntimeError(f"URI protocol {scheme!r} is not supported")

if self.offline and fetcher.requires_connection:
return None, ""
Expand Down
13 changes: 13 additions & 0 deletions tests/test_style.py
Expand Up @@ -834,3 +834,16 @@ def test_parsing_github_urls(original_url, expected_url, git_reference, raw_git_
assert gh.api_url == "https://api.github.com/repos/andreoliwa/nitpick"
assert gh.short_protocol_url == f"gh://andreoliwa/nitpick{at_reference}/src/nitpick/__init__.py"
assert gh.long_protocol_url == f"github://andreoliwa/nitpick{at_reference}/src/nitpick/__init__.py"


def test_protocol_not_supported(tmp_path):
"""Test unsupported protocols."""
project = ProjectMock(tmp_path).pyproject_toml(
"""
[tool.nitpick]
style = ["abc://www.example.com/style.toml"]
"""
)
with pytest.raises(RuntimeError) as exc_info:
project.api_check()
assert str(exc_info.value) == "URI protocol 'abc' is not supported"

0 comments on commit d4b5a0a

Please sign in to comment.