File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -174,25 +174,29 @@ def event_loop(request):
174174 loop .close ()
175175
176176
177- @pytest .fixture
178- def unused_tcp_port ():
177+ def _unused_tcp_port ():
179178 """Find an unused localhost TCP port from 1024-65535 and return it."""
180179 with contextlib .closing (socket .socket ()) as sock :
181180 sock .bind (('127.0.0.1' , 0 ))
182181 return sock .getsockname ()[1 ]
183182
184183
184+ @pytest .fixture
185+ def unused_tcp_port ():
186+ return _unused_tcp_port ()
187+
188+
185189@pytest .fixture
186190def unused_tcp_port_factory ():
187191 """A factory function, producing different unused TCP ports."""
188192 produced = set ()
189193
190194 def factory ():
191195 """Return an unused port."""
192- port = unused_tcp_port ()
196+ port = _unused_tcp_port ()
193197
194198 while port in produced :
195- port = unused_tcp_port ()
199+ port = _unused_tcp_port ()
196200
197201 produced .add (port )
198202
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ show_missing = true
77[tool:pytest]
88addopts = -rsx --tb =short
99testpaths = tests
10+ filterwarnings = error
1011
1112[metadata]
1213# ensure LICENSE is included in wheel metadata
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ def mock_unused_tcp_port():
104104 else :
105105 return 10000 + counter
106106
107- monkeypatch .setattr (pytest_asyncio .plugin , 'unused_tcp_port ' ,
107+ monkeypatch .setattr (pytest_asyncio .plugin , '_unused_tcp_port ' ,
108108 mock_unused_tcp_port )
109109
110110 assert unused_tcp_port_factory () == 10000
You can’t perform that action at this time.
0 commit comments