mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-05-02 06:36:20 -04:00
move _find_available_ports to chrome.py, changing the way it works so that browser:9200 doesn't get stuck at 9201 forever, which pushes 9201 to 9202 etc, and add a unit test
This commit is contained in:
parent
74009852d6
commit
ce03381b92
4 changed files with 42 additions and 21 deletions
|
@ -22,6 +22,9 @@ import http.server
|
|||
import threading
|
||||
import os
|
||||
import brozzler
|
||||
import brozzler.chrome
|
||||
import socket
|
||||
import logging
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def httpd(request):
|
||||
|
@ -52,3 +55,18 @@ 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():
|
||||
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 brozzler.chrome.Chrome._find_available_port(None, 9800) == 9800
|
||||
sock = socket.socket()
|
||||
sock.bind(('localhost', 9800))
|
||||
assert brozzler.chrome.Chrome._find_available_port(None, 9800) == 9999
|
||||
sock.close()
|
||||
assert brozzler.chrome.Chrome._find_available_port(None, 9800) == 9800
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue