Skip to content

Commit

Permalink
Merge pull request #15 from python-trio/njsmith-patch-1
Browse files Browse the repository at this point in the history
Remove unused_tcp_port{,_factory} fixtures
  • Loading branch information
touilleMan committed Dec 15, 2017
2 parents a30ffb1 + 59eb8b6 commit 12597a4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 27 deletions.
1 change: 1 addition & 0 deletions newsfragments/15.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove unused_tcp_port{,_factory} fixtures
27 changes: 0 additions & 27 deletions pytest_trio/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,33 +209,6 @@ def pytest_exception_interact(node, call, report):
report.longrepr = ''.join(format_exception(*call.excinfo._excinfo))


@pytest.fixture
def unused_tcp_port():
"""Find an unused localhost TCP port from 1024-65535 and return it."""
with contextlib.closing(socket.socket()) as sock:
sock.bind(('127.0.0.1', 0))
return sock.getsockname()[1]


@pytest.fixture
def unused_tcp_port_factory():
"""A factory function, producing different unused TCP ports."""
produced = set()

def factory():
"""Return an unused port."""
port = unused_tcp_port()

while port in produced:
port = unused_tcp_port()

produced.add(port)

return port

return factory


@pytest.fixture
def mock_clock():
return MockClock()
Expand Down

0 comments on commit 12597a4

Please sign in to comment.