Rev3802, Fix pytest warnings
This commit is contained in:
parent
f58f738fe4
commit
a7509988af
5 changed files with 17 additions and 12 deletions
|
@ -185,7 +185,7 @@ class TestBootstrapper:
|
||||||
assert len(site.peers) == 2
|
assert len(site.peers) == 2
|
||||||
assert "bka4ht2bzxchy44r.onion:1234" in site.peers
|
assert "bka4ht2bzxchy44r.onion:1234" in site.peers
|
||||||
|
|
||||||
@pytest.mark.skipif(not pytest.config.getvalue("slow"), reason="--slow not requested (takes around ~ 1min)")
|
@pytest.mark.slow
|
||||||
def testAnnounce(self, file_server, tor_manager):
|
def testAnnounce(self, file_server, tor_manager):
|
||||||
file_server.tor_manager = tor_manager
|
file_server.tor_manager = tor_manager
|
||||||
hash1 = hashlib.sha256("1Nekos4fiBqfcazyG1bAxdBT5oBvA76Z").digest()
|
hash1 = hashlib.sha256("1Nekos4fiBqfcazyG1bAxdBT5oBvA76Z").digest()
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Config(object):
|
||||||
|
|
||||||
def __init__(self, argv):
|
def __init__(self, argv):
|
||||||
self.version = "0.6.4"
|
self.version = "0.6.4"
|
||||||
self.rev = 3801
|
self.rev = 3802
|
||||||
self.argv = argv
|
self.argv = argv
|
||||||
self.action = None
|
self.action = None
|
||||||
self.pending_changes = {}
|
self.pending_changes = {}
|
||||||
|
|
|
@ -49,7 +49,7 @@ class TestTor:
|
||||||
# Delete
|
# Delete
|
||||||
tor_manager.delOnion(address)
|
tor_manager.delOnion(address)
|
||||||
|
|
||||||
@pytest.mark.skipif(not pytest.config.getvalue("slow"), reason="--slow not requested (takes around ~ 1min)")
|
@pytest.mark.slow
|
||||||
def testConnection(self, tor_manager, file_server, site, site_temp):
|
def testConnection(self, tor_manager, file_server, site, site_temp):
|
||||||
file_server.tor_manager.start_onions = True
|
file_server.tor_manager.start_onions = True
|
||||||
address = file_server.tor_manager.getOnion(site.address)
|
address = file_server.tor_manager.getOnion(site.address)
|
||||||
|
|
|
@ -128,7 +128,7 @@ class TestUpnpPunch(object):
|
||||||
rsp = httplib_response(status=500)
|
rsp = httplib_response(status=500)
|
||||||
with pytest.raises(upnp.IGDError) as exc:
|
with pytest.raises(upnp.IGDError) as exc:
|
||||||
upnp._parse_for_errors(rsp)
|
upnp._parse_for_errors(rsp)
|
||||||
assert 'Unable to parse' in exc.value.message
|
assert 'Unable to parse' in str(exc)
|
||||||
|
|
||||||
def test_parse_for_errors_error(self, httplib_response):
|
def test_parse_for_errors_error(self, httplib_response):
|
||||||
soap_error = ('<document>'
|
soap_error = ('<document>'
|
||||||
|
@ -138,7 +138,7 @@ class TestUpnpPunch(object):
|
||||||
rsp = httplib_response(status=500, body=soap_error)
|
rsp = httplib_response(status=500, body=soap_error)
|
||||||
with pytest.raises(upnp.IGDError) as exc:
|
with pytest.raises(upnp.IGDError) as exc:
|
||||||
upnp._parse_for_errors(rsp)
|
upnp._parse_for_errors(rsp)
|
||||||
assert 'SOAP request error' in exc.value.message
|
assert 'SOAP request error' in str(exc)
|
||||||
|
|
||||||
def test_parse_for_errors_good_rsp(self, httplib_response):
|
def test_parse_for_errors_good_rsp(self, httplib_response):
|
||||||
rsp = httplib_response(status=200)
|
rsp = httplib_response(status=200)
|
||||||
|
|
|
@ -18,6 +18,15 @@ monkey.patch_all(thread=False, subprocess=False)
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
parser.addoption("--slow", action='store_true', default=False, help="Also run slow tests")
|
parser.addoption("--slow", action='store_true', default=False, help="Also run slow tests")
|
||||||
|
|
||||||
|
def pytest_collection_modifyitems(config, items):
|
||||||
|
if config.getoption("--slow"):
|
||||||
|
# --runslow given in cli: do not skip slow tests
|
||||||
|
return
|
||||||
|
skip_slow = pytest.mark.skip(reason="need --slow option to run")
|
||||||
|
for item in items:
|
||||||
|
if "slow" in item.keywords:
|
||||||
|
item.add_marker(skip_slow)
|
||||||
|
|
||||||
# Config
|
# Config
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
CHROMEDRIVER_PATH = "tools/chrome/chromedriver.exe"
|
CHROMEDRIVER_PATH = "tools/chrome/chromedriver.exe"
|
||||||
|
@ -90,10 +99,6 @@ from Content import ContentDb
|
||||||
from util import RateLimit
|
from util import RateLimit
|
||||||
from Db import Db
|
from Db import Db
|
||||||
|
|
||||||
# SiteManager.site_manager.load = mock.MagicMock(return_value=True) # Don't try to load from sites.json
|
|
||||||
# SiteManager.site_manager.save = mock.MagicMock(return_value=True) # Don't try to load from sites.json
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def resetSettings(request):
|
def resetSettings(request):
|
||||||
open("%s/sites.json" % config.data_dir, "w").write("{}")
|
open("%s/sites.json" % config.data_dir, "w").write("{}")
|
||||||
|
@ -204,7 +209,7 @@ def browser(request):
|
||||||
options.add_argument("--headless")
|
options.add_argument("--headless")
|
||||||
options.add_argument("--window-size=1920x1080")
|
options.add_argument("--window-size=1920x1080")
|
||||||
options.add_argument("--log-level=1")
|
options.add_argument("--log-level=1")
|
||||||
browser = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, service_log_path=os.path.devnull, chrome_options=options)
|
browser = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, service_log_path=os.path.devnull, options=options)
|
||||||
|
|
||||||
def quit():
|
def quit():
|
||||||
browser.quit()
|
browser.quit()
|
||||||
|
@ -226,9 +231,9 @@ def site_url():
|
||||||
@pytest.fixture(params=['ipv4', 'ipv6'])
|
@pytest.fixture(params=['ipv4', 'ipv6'])
|
||||||
def file_server(request):
|
def file_server(request):
|
||||||
if request.param == "ipv4":
|
if request.param == "ipv4":
|
||||||
return request.getfuncargvalue("file_server4")
|
return request.getfixturevalue("file_server4")
|
||||||
else:
|
else:
|
||||||
return request.getfuncargvalue("file_server6")
|
return request.getfixturevalue("file_server6")
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|
Loading…
Reference in a new issue