Shorten argument name

This commit is contained in:
Paul O'Leary McCann 2022-12-26 20:15:16 +09:00
parent c0b2472211
commit c16286f99e
2 changed files with 5 additions and 5 deletions

View File

@ -445,5 +445,5 @@ def test_find_available_port():
with make_server(host, port, demo_app) as httpd: with make_server(host, port, demo_app) as httpd:
with pytest.warns(UserWarning, match="already in use"): with pytest.warns(UserWarning, match="already in use"):
found_port = find_available_port(port, host, auto_select_port=True) found_port = find_available_port(port, host, auto_select=True)
assert found_port == port + 1, "Didn't find next port" assert found_port == port + 1, "Didn't find next port"

View File

@ -1751,18 +1751,18 @@ def is_port_in_use(port, host="localhost"):
s.close() s.close()
def find_available_port(start, host, auto_select_port=False): def find_available_port(start, host, auto_select=False):
"""Given a starting port and a host, handle finding a port. """Given a starting port and a host, handle finding a port.
If `auto_select_port` is False, a busy port will raise an error. If `auto_select` is False, a busy port will raise an error.
If `auto_select_port` is True, the next free higher port will be used. If `auto_select` is True, the next free higher port will be used.
""" """
if not is_port_in_use(start, host): if not is_port_in_use(start, host):
return start return start
port = start port = start
if not auto_select_port: if not auto_select:
raise ValueError(Errors.E1049.format(port=port)) raise ValueError(Errors.E1049.format(port=port))
while is_port_in_use(port, host) and port < 65535: while is_port_in_use(port, host) and port < 65535: