Tests: TestUnit class removed.
Prerequisite checks moved to the fixture in conftest.py.
This commit is contained in:
@@ -184,6 +184,40 @@ def pytest_runtest_makereport(item, call):
|
|||||||
setattr(item, "rep_" + rep.when, rep)
|
setattr(item, "rep_" + rep.when, rep)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope='class', autouse=True)
|
||||||
|
def check_prerequisites(request):
|
||||||
|
cls = request.cls
|
||||||
|
missed = []
|
||||||
|
|
||||||
|
# check modules
|
||||||
|
|
||||||
|
if 'modules' in cls.prerequisites:
|
||||||
|
available_modules = list(option.available['modules'].keys())
|
||||||
|
|
||||||
|
for module in cls.prerequisites['modules']:
|
||||||
|
if module in available_modules:
|
||||||
|
continue
|
||||||
|
|
||||||
|
missed.append(module)
|
||||||
|
|
||||||
|
if missed:
|
||||||
|
pytest.skip('Unit has no ' + ', '.join(missed) + ' module(s)')
|
||||||
|
|
||||||
|
# check features
|
||||||
|
|
||||||
|
if 'features' in cls.prerequisites:
|
||||||
|
available_features = list(option.available['features'].keys())
|
||||||
|
|
||||||
|
for feature in cls.prerequisites['features']:
|
||||||
|
if feature in available_features:
|
||||||
|
continue
|
||||||
|
|
||||||
|
missed.append(feature)
|
||||||
|
|
||||||
|
if missed:
|
||||||
|
pytest.skip(', '.join(missed) + ' feature(s) not supported')
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def run(request):
|
def run(request):
|
||||||
unit = unit_run()
|
unit = unit_run()
|
||||||
|
|||||||
@@ -7,11 +7,10 @@ import select
|
|||||||
import socket
|
import socket
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from unit.main import TestUnit
|
|
||||||
from unit.option import option
|
from unit.option import option
|
||||||
|
|
||||||
|
|
||||||
class TestHTTP(TestUnit):
|
class TestHTTP():
|
||||||
def http(self, start_str, **kwargs):
|
def http(self, start_str, **kwargs):
|
||||||
sock_type = kwargs.get('sock_type', 'ipv4')
|
sock_type = kwargs.get('sock_type', 'ipv4')
|
||||||
port = kwargs.get('port', 7080)
|
port = kwargs.get('port', 7080)
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
import pytest
|
|
||||||
from unit.option import option
|
|
||||||
|
|
||||||
|
|
||||||
class TestUnit():
|
|
||||||
@classmethod
|
|
||||||
def setup_class(cls):
|
|
||||||
missed = []
|
|
||||||
|
|
||||||
# check modules
|
|
||||||
|
|
||||||
if 'modules' in cls.prerequisites:
|
|
||||||
available_modules = list(option.available['modules'].keys())
|
|
||||||
|
|
||||||
for module in cls.prerequisites['modules']:
|
|
||||||
if module in available_modules:
|
|
||||||
continue
|
|
||||||
|
|
||||||
missed.append(module)
|
|
||||||
|
|
||||||
if missed:
|
|
||||||
pytest.skip('Unit has no ' + ', '.join(missed) + ' module(s)')
|
|
||||||
|
|
||||||
# check features
|
|
||||||
|
|
||||||
if 'features' in cls.prerequisites:
|
|
||||||
available_features = list(option.available['features'].keys())
|
|
||||||
|
|
||||||
for feature in cls.prerequisites['features']:
|
|
||||||
if feature in available_features:
|
|
||||||
continue
|
|
||||||
|
|
||||||
missed.append(feature)
|
|
||||||
|
|
||||||
if missed:
|
|
||||||
pytest.skip(', '.join(missed) + ' feature(s) not supported')
|
|
||||||
Reference in New Issue
Block a user