Skip to content

Commit

Permalink
Merge branch 'master' into mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
palfrey committed Dec 21, 2022
2 parents a233600 + 7755b60 commit cb4ece1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/pycqa/isort
rev: "5.10.1"
rev: "v5.11.3"
hooks:
- id: isort
args: ["--profile", "black"]
Expand Down
8 changes: 7 additions & 1 deletion dj_database_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ def parse(
hostname = urlparse.unquote(hostname)

# Lookup specified engine.
engine = SCHEMES[spliturl.scheme] if engine is None else engine
if engine is None:
engine = SCHEMES.get(spliturl.scheme)
if engine is None:
raise ValueError(
"No support for '%s'. We support: %s"
% (spliturl.scheme, ", ".join(sorted(SCHEMES.keys())))
)

port = (
str(spliturl.port)
Expand Down
4 changes: 4 additions & 0 deletions test_dj_database_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,10 @@ def test_persistent_connection_variables_config(self):
assert url["CONN_MAX_AGE"] == 600
assert url["CONN_HEALTH_CHECKS"] is True

def test_bad_url_parsing(self):
with self.assertRaisesRegex(ValueError, "No support for 'foo'. We support: "):
dj_database_url.parse("foo://bar")


if __name__ == "__main__":
unittest.main()

0 comments on commit cb4ece1

Please sign in to comment.