File tree 3 files changed +10
-6
lines changed
3 files changed +10
-6
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 @@ -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
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ minversion = 2.5.0
4
4
5
5
[testenv]
6
6
extras = testing
7
- commands = coverage run -m pytest {posargs}
7
+ commands = coverage run -m pytest -W error {posargs}
8
8
9
9
[testenv:coverage-report]
10
10
deps = coverage
You can’t perform that action at this time.
0 commit comments