Skip to content

Commit

Permalink
Merge pull request #28 from kmike/none
Browse files Browse the repository at this point in the history
Update typing allowing get_port to select any available port randomly
  • Loading branch information
fizyk committed Jun 1, 2021
2 parents 0b26116 + a94da7a commit f322bad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/port_for/api.py
Expand Up @@ -127,6 +127,7 @@ def filter_by_type(lst: Iterable, type_of: Type[T]) -> List[T]:

def get_port(
ports: Union[
None,
str,
int,
Tuple[int, int],
Expand Down
5 changes: 5 additions & 0 deletions tests/test_cases.py
Expand Up @@ -51,6 +51,11 @@ def test_binding_high() -> None:
assert not port_for.port_is_used(port)


def test_get_port_random() -> None:
"""Test case allowing get port to randomly select any port."""
assert get_port(None)


def test_get_port_none() -> None:
"""Test special case for get_port to return None."""
assert not get_port(-1)
Expand Down

0 comments on commit f322bad

Please sign in to comment.