mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Use get_unused_port utility method
This commit is contained in:
parent
d3a67d5376
commit
90eb157171
1 changed files with 2 additions and 7 deletions
|
@ -1,8 +1,6 @@
|
|||
import socket
|
||||
from contextlib import closing
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
from pytestshellutils.utils import ports
|
||||
from werkzeug.wrappers import Response # pylint: disable=3rd-party-module-not-gated
|
||||
|
||||
import salt.utils.http as http
|
||||
|
@ -150,10 +148,7 @@ def test_query_null_response():
|
|||
"""
|
||||
host = "127.0.0.1"
|
||||
|
||||
# Find unused port
|
||||
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock:
|
||||
sock.bind((host, 0))
|
||||
port = sock.getsockname()[1]
|
||||
port = ports.get_unused_localhost_port()
|
||||
|
||||
url = "http://{host}:{port}/".format(host=host, port=port)
|
||||
result = http.query(url, raise_error=False)
|
||||
|
|
Loading…
Add table
Reference in a new issue