diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2020-12-06 16:01:59 +0000 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2020-12-06 16:01:59 +0000 |
commit | 07789a23e9c513dba87b020fae2989a57955e8a6 (patch) | |
tree | aa5b77497ee957b79a67f70df796c0da49447a22 /test | |
parent | 55296e6ff2613a0b2ec588beaf01620b2679c3d1 (diff) | |
download | unit-07789a23e9c513dba87b020fae2989a57955e8a6.tar.gz unit-07789a23e9c513dba87b020fae2989a57955e8a6.tar.bz2 |
Tests: options moved to the separate class.
This change is necessary to separate the logic
and prevent possible circular dependency.
Diffstat (limited to 'test')
39 files changed, 62 insertions, 41 deletions
diff --git a/test/conftest.py b/test/conftest.py index 3edc471d..8ca8c1d3 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -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']) diff --git a/test/test_access_log.py b/test/test_access_log.py index 511ce6c5..0a0a6633 100644 --- a/test/test_access_log.py +++ b/test/test_access_log.py @@ -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): diff --git a/test/test_asgi_application.py b/test/test_asgi_application.py index e90d78bc..80b64029 100644 --- a/test/test_asgi_application.py +++ b/test/test_asgi_application.py @@ -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): diff --git a/test/test_asgi_lifespan.py b/test/test_asgi_lifespan.py index 3f29c7e7..409634bb 100644 --- a/test/test_asgi_lifespan.py +++ b/test/test_asgi_lifespan.py @@ -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): diff --git a/test/test_asgi_websockets.py b/test/test_asgi_websockets.py index 54984526..766e53ed 100644 --- a/test/test_asgi_websockets.py +++ b/test/test_asgi_websockets.py @@ -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): diff --git a/test/test_go_isolation.py b/test/test_go_isolation.py index 8c4a6b9c..ac12c8ca 100644 --- a/test/test_go_isolation.py +++ b/test/test_go_isolation.py @@ -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']} diff --git a/test/test_java_application.py b/test/test_java_application.py index 41345e87..04210ebf 100644 --- a/test/test_java_application.py +++ b/test/test_java_application.py @@ -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'}} diff --git a/test/test_java_isolation_rootfs.py b/test/test_java_isolation_rootfs.py index 02d35a62..a401e23b 100644 --- a/test/test_java_isolation_rootfs.py +++ b/test/test_java_isolation_rootfs.py @@ -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): diff --git a/test/test_java_websockets.py b/test/test_java_websockets.py index 7586d4aa..5739e236 100644 --- a/test/test_java_websockets.py +++ b/test/test_java_websockets.py @@ -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): diff --git a/test/test_node_websockets.py b/test/test_node_websockets.py index 7b65b5c1..84eb4c42 100644 --- a/test/test_node_websockets.py +++ b/test/test_node_websockets.py @@ -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): diff --git a/test/test_php_application.py b/test/test_php_application.py index 578de0b7..463ec35b 100644 --- a/test/test_php_application.py +++ b/test/test_php_application.py @@ -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'}} diff --git a/test/test_php_isolation.py b/test/test_php_isolation.py index cc660e04..1d0b0614 100644 --- a/test/test_php_isolation.py +++ b/test/test_php_isolation.py @@ -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): diff --git a/test/test_php_targets.py b/test/test_php_targets.py index e64cd6b6..76326131 100644 --- a/test/test_php_targets.py +++ b/test/test_php_targets.py @@ -1,5 +1,5 @@ -from conftest import option from unit.applications.lang.php import TestApplicationPHP +from unit.option import option class TestPHPTargets(TestApplicationPHP): diff --git a/test/test_proxy.py b/test/test_proxy.py index be3e93fd..90b6b657 100644 --- a/test/test_proxy.py +++ b/test/test_proxy.py @@ -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): diff --git a/test/test_proxy_chunked.py b/test/test_proxy_chunked.py index ae2228fa..5529b397 100644 --- a/test/test_proxy_chunked.py +++ b/test/test_proxy_chunked.py @@ -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): diff --git a/test/test_python_application.py b/test/test_python_application.py index 83b0c8f4..b28e8c11 100644 --- a/test/test_python_application.py +++ b/test/test_python_application.py @@ -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): diff --git a/test/test_python_isolation.py b/test/test_python_isolation.py index 1a157528..66ff2f16 100644 --- a/test/test_python_isolation.py +++ b/test/test_python_isolation.py @@ -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): diff --git a/test/test_python_procman.py b/test/test_python_procman.py index ff914fc8..42a197a7 100644 --- a/test/test_python_procman.py +++ b/test/test_python_procman.py @@ -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): diff --git a/test/test_respawn.py b/test/test_respawn.py index 09a806d4..fbaad666 100644 --- a/test/test_respawn.py +++ b/test/test_respawn.py @@ -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): diff --git a/test/test_routing.py b/test/test_routing.py index 83852273..a49075ae 100644 --- a/test/test_routing.py +++ b/test/test_routing.py @@ -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): diff --git a/test/test_ruby_isolation.py b/test/test_ruby_isolation.py index 69e25de9..56fccbd0 100644 --- a/test/test_ruby_isolation.py +++ b/test/test_ruby_isolation.py @@ -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): diff --git a/test/test_share_fallback.py b/test/test_share_fallback.py index 462da9de..151d3ae5 100644 --- a/test/test_share_fallback.py +++ b/test/test_share_fallback.py @@ -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): diff --git a/test/test_static.py b/test/test_static.py index a65928ca..1df0c902 100644 --- a/test/test_static.py +++ b/test/test_static.py @@ -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): diff --git a/test/test_tls.py b/test/test_tls.py index 4cf8d22c..32b97895 100644 --- a/test/test_tls.py +++ b/test/test_tls.py @@ -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): diff --git a/test/test_upstreams_rr.py b/test/test_upstreams_rr.py index c20d6054..163eb646 100644 --- a/test/test_upstreams_rr.py +++ b/test/test_upstreams_rr.py @@ -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): diff --git a/test/unit/applications/lang/go.py b/test/unit/applications/lang/go.py index 866dec47..70f9d58c 100644 --- a/test/unit/applications/lang/go.py +++ b/test/unit/applications/lang/go.py @@ -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): diff --git a/test/unit/applications/lang/java.py b/test/unit/applications/lang/java.py index 0ff85187..b2e17f23 100644 --- a/test/unit/applications/lang/java.py +++ b/test/unit/applications/lang/java.py @@ -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): diff --git a/test/unit/applications/lang/node.py b/test/unit/applications/lang/node.py index 98fd9ffc..baccef7e 100644 --- a/test/unit/applications/lang/node.py +++ b/test/unit/applications/lang/node.py @@ -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): diff --git a/test/unit/applications/lang/perl.py b/test/unit/applications/lang/perl.py index 9dc24ace..58b867f0 100644 --- a/test/unit/applications/lang/perl.py +++ b/test/unit/applications/lang/perl.py @@ -1,5 +1,5 @@ -from conftest import option from unit.applications.proto import TestApplicationProto +from unit.option import option class TestApplicationPerl(TestApplicationProto): diff --git a/test/unit/applications/lang/php.py b/test/unit/applications/lang/php.py index 3dbb32f5..90c0078c 100644 --- a/test/unit/applications/lang/php.py +++ b/test/unit/applications/lang/php.py @@ -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): diff --git a/test/unit/applications/lang/python.py b/test/unit/applications/lang/python.py index 792a86fa..287d23f0 100644 --- a/test/unit/applications/lang/python.py +++ b/test/unit/applications/lang/python.py @@ -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): diff --git a/test/unit/applications/lang/ruby.py b/test/unit/applications/lang/ruby.py index 82d66e65..02644584 100644 --- a/test/unit/applications/lang/ruby.py +++ b/test/unit/applications/lang/ruby.py @@ -1,5 +1,5 @@ -from conftest import option from unit.applications.proto import TestApplicationProto +from unit.option import option class TestApplicationRuby(TestApplicationProto): diff --git a/test/unit/applications/proto.py b/test/unit/applications/proto.py index 6e760c70..af05d071 100644 --- a/test/unit/applications/proto.py +++ b/test/unit/applications/proto.py @@ -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): diff --git a/test/unit/applications/tls.py b/test/unit/applications/tls.py index fb1b112c..b0cd5abb 100644 --- a/test/unit/applications/tls.py +++ b/test/unit/applications/tls.py @@ -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): diff --git a/test/unit/control.py b/test/unit/control.py index f05aa827..3008a64b 100644 --- a/test/unit/control.py +++ b/test/unit/control.py @@ -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): diff --git a/test/unit/feature/isolation.py b/test/unit/feature/isolation.py index 7877c03a..d8f68919 100644 --- a/test/unit/feature/isolation.py +++ b/test/unit/feature/isolation.py @@ -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): diff --git a/test/unit/http.py b/test/unit/http.py index 8d964978..ae74eac3 100644 --- a/test/unit/http.py +++ b/test/unit/http.py @@ -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): diff --git a/test/unit/main.py b/test/unit/main.py index 488b3f4d..fce6a322 100644 --- a/test/unit/main.py +++ b/test/unit/main.py @@ -1,5 +1,5 @@ import pytest -from conftest import option +from unit.option import option class TestUnit(): diff --git a/test/unit/option.py b/test/unit/option.py new file mode 100644 index 00000000..677d806e --- /dev/null +++ b/test/unit/option.py @@ -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() |