File tree 3 files changed +10
-5
lines changed
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):
174
174
loop .close ()
175
175
176
176
177
- @pytest .fixture
178
- def unused_tcp_port ():
177
+ def _unused_tcp_port ():
179
178
"""Find an unused localhost TCP port from 1024-65535 and return it."""
180
179
with contextlib .closing (socket .socket ()) as sock :
181
180
sock .bind (('127.0.0.1' , 0 ))
182
181
return sock .getsockname ()[1 ]
183
182
184
183
184
+ @pytest .fixture
185
+ def unused_tcp_port ():
186
+ return _unused_tcp_port ()
187
+
188
+
185
189
@pytest .fixture
186
190
def unused_tcp_port_factory ():
187
191
"""A factory function, producing different unused TCP ports."""
188
192
produced = set ()
189
193
190
194
def factory ():
191
195
"""Return an unused port."""
192
- port = unused_tcp_port ()
196
+ port = _unused_tcp_port ()
193
197
194
198
while port in produced :
195
- port = unused_tcp_port ()
199
+ port = _unused_tcp_port ()
196
200
197
201
produced .add (port )
198
202
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ show_missing = true
7
7
[tool:pytest]
8
8
addopts = -rsx --tb =short
9
9
testpaths = tests
10
+ filterwarnings = error
10
11
11
12
[metadata]
12
13
# 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():
104
104
else :
105
105
return 10000 + counter
106
106
107
- monkeypatch .setattr (pytest_asyncio .plugin , 'unused_tcp_port ' ,
107
+ monkeypatch .setattr (pytest_asyncio .plugin , '_unused_tcp_port ' ,
108
108
mock_unused_tcp_port )
109
109
110
110
assert unused_tcp_port_factory () == 10000
You can’t perform that action at this time.
0 commit comments