Tests: options moved to the separate class.
This change is necessary to separate the logic and prevent possible circular dependency.
This commit is contained in:
@@ -17,6 +17,7 @@ import pytest
|
||||
from unit.check.go import check_go
|
||||
from unit.check.node import check_node
|
||||
from unit.check.tls import check_openssl
|
||||
from unit.option import option
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
@@ -48,12 +49,14 @@ def pytest_addoption(parser):
|
||||
|
||||
unit_instance = {}
|
||||
_processes = []
|
||||
option = None
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
global option
|
||||
option = config.option
|
||||
option.config = config.option
|
||||
|
||||
option.detailed = config.option.detailed
|
||||
option.print_log = config.option.print_log
|
||||
option.save_log = config.option.save_log
|
||||
option.unsafe = config.option.unsafe
|
||||
|
||||
option.generated_tests = {}
|
||||
option.current_dir = os.path.abspath(
|
||||
@@ -162,6 +165,8 @@ def pytest_sessionstart(session):
|
||||
|
||||
unit_stop()
|
||||
|
||||
_check_alerts()
|
||||
|
||||
shutil.rmtree(unit_instance['temp_dir'])
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ import time
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import unit_stop
|
||||
from unit.applications.lang.python import TestApplicationPython
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestAccessLog(TestApplicationPython):
|
||||
|
||||
@@ -4,9 +4,9 @@ from distutils.version import LooseVersion
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import skip_alert
|
||||
from unit.applications.lang.python import TestApplicationPython
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestASGIApplication(TestApplicationPython):
|
||||
|
||||
@@ -3,10 +3,10 @@ from distutils.version import LooseVersion
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import public_dir
|
||||
from conftest import unit_stop
|
||||
from unit.applications.lang.python import TestApplicationPython
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestASGILifespan(TestApplicationPython):
|
||||
|
||||
@@ -4,10 +4,10 @@ from distutils.version import LooseVersion
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import skip_alert
|
||||
from unit.applications.lang.python import TestApplicationPython
|
||||
from unit.applications.websockets import TestApplicationWebsocket
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestASGIWebsockets(TestApplicationPython):
|
||||
|
||||
@@ -5,11 +5,11 @@ import shutil
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import unit_run
|
||||
from conftest import unit_stop
|
||||
from unit.applications.lang.go import TestApplicationGo
|
||||
from unit.feature.isolation import TestFeatureIsolation
|
||||
from unit.option import option
|
||||
|
||||
class TestGoIsolation(TestApplicationGo):
|
||||
prerequisites = {'modules': {'go': 'any'}, 'features': ['isolation']}
|
||||
|
||||
@@ -3,10 +3,10 @@ import os
|
||||
import re
|
||||
import time
|
||||
|
||||
from conftest import option
|
||||
from conftest import public_dir
|
||||
from conftest import skip_alert
|
||||
from unit.applications.lang.java import TestApplicationJava
|
||||
from unit.option import option
|
||||
|
||||
class TestJavaApplication(TestApplicationJava):
|
||||
prerequisites = {'modules': {'java': 'all'}}
|
||||
|
||||
@@ -3,8 +3,8 @@ import subprocess
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from unit.applications.lang.java import TestApplicationJava
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestJavaIsolationRootfs(TestApplicationJava):
|
||||
|
||||
@@ -3,10 +3,10 @@ import time
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import skip_alert
|
||||
from unit.applications.lang.java import TestApplicationJava
|
||||
from unit.applications.websockets import TestApplicationWebsocket
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestJavaWebsockets(TestApplicationJava):
|
||||
|
||||
@@ -3,10 +3,10 @@ import time
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import skip_alert
|
||||
from unit.applications.lang.node import TestApplicationNode
|
||||
from unit.applications.websockets import TestApplicationWebsocket
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestNodeWebsockets(TestApplicationNode):
|
||||
|
||||
@@ -5,9 +5,9 @@ import time
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import unit_stop
|
||||
from unit.applications.lang.php import TestApplicationPHP
|
||||
from unit.option import option
|
||||
|
||||
class TestPHPApplication(TestApplicationPHP):
|
||||
prerequisites = {'modules': {'php': 'all'}}
|
||||
|
||||
@@ -2,11 +2,11 @@ import shutil
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import unit_run
|
||||
from conftest import unit_stop
|
||||
from unit.applications.lang.php import TestApplicationPHP
|
||||
from unit.feature.isolation import TestFeatureIsolation
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestPHPIsolation(TestApplicationPHP):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from conftest import option
|
||||
from unit.applications.lang.php import TestApplicationPHP
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestPHPTargets(TestApplicationPHP):
|
||||
|
||||
@@ -4,11 +4,11 @@ import time
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import run_process
|
||||
from conftest import skip_alert
|
||||
from conftest import waitforsocket
|
||||
from unit.applications.lang.python import TestApplicationPython
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestProxy(TestApplicationPython):
|
||||
|
||||
@@ -3,10 +3,10 @@ import select
|
||||
import socket
|
||||
import time
|
||||
|
||||
from conftest import option
|
||||
from conftest import run_process
|
||||
from conftest import waitforsocket
|
||||
from unit.applications.lang.python import TestApplicationPython
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestProxyChunked(TestApplicationPython):
|
||||
|
||||
@@ -5,10 +5,10 @@ import time
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import skip_alert
|
||||
from conftest import unit_stop
|
||||
from unit.applications.lang.python import TestApplicationPython
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestPythonApplication(TestApplicationPython):
|
||||
|
||||
@@ -2,11 +2,11 @@ import shutil
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import unit_run
|
||||
from conftest import unit_stop
|
||||
from unit.applications.lang.python import TestApplicationPython
|
||||
from unit.feature.isolation import TestFeatureIsolation
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestPythonIsolation(TestApplicationPython):
|
||||
|
||||
@@ -4,8 +4,8 @@ import time
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from unit.applications.lang.python import TestApplicationPython
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestPythonProcman(TestApplicationPython):
|
||||
|
||||
@@ -2,9 +2,9 @@ import re
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
from conftest import option
|
||||
from conftest import skip_alert
|
||||
from unit.applications.lang.python import TestApplicationPython
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestRespawn(TestApplicationPython):
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import skip_alert
|
||||
from unit.applications.proto import TestApplicationProto
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestRouting(TestApplicationProto):
|
||||
|
||||
@@ -2,11 +2,11 @@ import shutil
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import unit_run
|
||||
from conftest import unit_stop
|
||||
from unit.applications.lang.ruby import TestApplicationRuby
|
||||
from unit.feature.isolation import TestFeatureIsolation
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestRubyIsolation(TestApplicationRuby):
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import os
|
||||
|
||||
from conftest import option
|
||||
from conftest import skip_alert
|
||||
from unit.applications.proto import TestApplicationProto
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestStatic(TestApplicationProto):
|
||||
|
||||
@@ -3,9 +3,9 @@ import socket
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import waitforfiles
|
||||
from unit.applications.proto import TestApplicationProto
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestStatic(TestApplicationProto):
|
||||
|
||||
@@ -5,9 +5,9 @@ import subprocess
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import option
|
||||
from conftest import skip_alert
|
||||
from unit.applications.tls import TestApplicationTLS
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestTLS(TestApplicationTLS):
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import os
|
||||
import re
|
||||
|
||||
from conftest import option
|
||||
from unit.applications.lang.python import TestApplicationPython
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestUpstreamsRR(TestApplicationPython):
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from conftest import option
|
||||
from unit.applications.proto import TestApplicationProto
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestApplicationGo(TestApplicationProto):
|
||||
|
||||
@@ -4,8 +4,8 @@ import shutil
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
from conftest import option
|
||||
from unit.applications.proto import TestApplicationProto
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestApplicationJava(TestApplicationProto):
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import shutil
|
||||
from urllib.parse import quote
|
||||
|
||||
from conftest import option
|
||||
from conftest import public_dir
|
||||
from unit.applications.proto import TestApplicationProto
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestApplicationNode(TestApplicationProto):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from conftest import option
|
||||
from unit.applications.proto import TestApplicationProto
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestApplicationPerl(TestApplicationProto):
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from conftest import option
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from unit.applications.proto import TestApplicationProto
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestApplicationPHP(TestApplicationProto):
|
||||
|
||||
@@ -3,8 +3,8 @@ import shutil
|
||||
from urllib.parse import quote
|
||||
|
||||
import pytest
|
||||
from conftest import option
|
||||
from unit.applications.proto import TestApplicationProto
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestApplicationPython(TestApplicationProto):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from conftest import option
|
||||
from unit.applications.proto import TestApplicationProto
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestApplicationRuby(TestApplicationProto):
|
||||
|
||||
@@ -2,8 +2,8 @@ import os
|
||||
import re
|
||||
import time
|
||||
|
||||
from conftest import option
|
||||
from unit.control import TestControl
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestApplicationProto(TestControl):
|
||||
|
||||
@@ -2,8 +2,8 @@ import os
|
||||
import ssl
|
||||
import subprocess
|
||||
|
||||
from conftest import option
|
||||
from unit.applications.proto import TestApplicationProto
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestApplicationTLS(TestApplicationProto):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
|
||||
from conftest import option
|
||||
from unit.http import TestHTTP
|
||||
from unit.option import option
|
||||
|
||||
|
||||
def args_handler(conf_func):
|
||||
|
||||
@@ -4,7 +4,7 @@ from unit.applications.lang.go import TestApplicationGo
|
||||
from unit.applications.lang.java import TestApplicationJava
|
||||
from unit.applications.lang.node import TestApplicationNode
|
||||
from unit.applications.proto import TestApplicationProto
|
||||
from conftest import option
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestFeatureIsolation(TestApplicationProto):
|
||||
|
||||
@@ -7,8 +7,8 @@ import select
|
||||
import socket
|
||||
|
||||
import pytest
|
||||
from conftest import option
|
||||
from unit.main import TestUnit
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestHTTP(TestUnit):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
from conftest import option
|
||||
from unit.option import option
|
||||
|
||||
|
||||
class TestUnit():
|
||||
|
||||
16
test/unit/option.py
Normal file
16
test/unit/option.py
Normal file
@@ -0,0 +1,16 @@
|
||||
class Options():
|
||||
_options = {
|
||||
'skip_alerts': [],
|
||||
'skip_sanitizer': False,
|
||||
}
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
Options._options[name] = value
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name in Options._options:
|
||||
return Options._options[name]
|
||||
|
||||
raise AttributeError
|
||||
|
||||
option = Options()
|
||||
Reference in New Issue
Block a user