let the OS pick an available port, to avoid what appear to be timing issues causing multiple browsers to choose the same port

This commit is contained in:
Noah Levitt 2017-02-22 12:44:19 -08:00
parent 3c4ab834da
commit 2398031010
4 changed files with 19 additions and 55 deletions

View file

@ -25,7 +25,6 @@ import brozzler
import brozzler.chrome
import socket
import logging
import psutil
import yaml
@pytest.fixture(scope='module')
@ -57,23 +56,6 @@ def test_robots(httpd):
site = brozzler.Site(seed=url, user_agent='im/a bAdBOt/uh huh')
assert not brozzler.is_permitted_by_robots(site, url)
def test_find_available_port():
x = brozzler.chrome.Chrome(None, None)
try:
psutil.net_connections(kind='tcp')
except psutil.AccessDenied:
logging.warn(
'skipping _find_available_port() test because '
'psutil.net_connections(kind="tcp") raised AccessDenied')
return
assert x._find_available_port(9800) == 9800
sock = socket.socket()
sock.bind(('localhost', 9800))
sock.listen(0)
assert x._find_available_port(9800) >= 9990
sock.close()
assert x._find_available_port(9800) == 9800
def test_scoping():
test_scope = yaml.load('''
max_hops: 100