Skip to content

Commit

Permalink
Add invalid port exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Nagico committed Dec 27, 2022
1 parent 0ae2f73 commit bc8da3d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dj_database_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def parse(
if engine == "djongo": # compatible with multiple host:port
port = None
else:
raise e
raise ValueError(f'Port parse error: {e}')

# Update with environment configuration.
parsed_config.update(
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 @@ -653,6 +653,10 @@ def test_bad_url_parsing(self):
with self.assertRaisesRegex(ValueError, "No support for 'foo'. We support: "):
dj_database_url.parse("foo://bar")

def test_bad_port_parsing(self):
with self.assertRaisesRegex(Exception, "Port parse error"):
dj_database_url.parse("mysql://foo:bar@localhost:65536/db")


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

0 comments on commit bc8da3d

Please sign in to comment.