diff --git a/tests_integrity/test_aes_session.py b/tests_integrity/test_aes_session.py index a629da7..ecdd975 100644 --- a/tests_integrity/test_aes_session.py +++ b/tests_integrity/test_aes_session.py @@ -7,7 +7,6 @@ from .support import check_url, start_server -# pylint: disable=inconsistent-return-statements # pylint: disable=missing-function-docstring # pylint: disable=no-self-use # pylint: disable=redefined-outer-name @@ -16,17 +15,19 @@ @fixture(scope="module") def url(request): """The URL (server fixture).""" - val = environ.get("TEST_AES_SESSION_URL", "").strip('/') + process = None + val = environ.get("TEST_AES_SESSION_URL", "").rstrip('/') if val: - return val - - process = start_server( - request, - join(dirname(__file__), pardir, 'examples/aes_session.py')) - - yield "http://localhost:8080" # server is running - process.kill() - process.wait() + yield val + else: + process = start_server( + request, + join(dirname(__file__), pardir, 'examples/aes_session.py')) + yield "http://localhost:8080" # server is running + + if process is not None: + process.kill() + process.wait() @fixture diff --git a/tests_integrity/test_digest.py b/tests_integrity/test_digest.py index a4feae7..bf1c489 100644 --- a/tests_integrity/test_digest.py +++ b/tests_integrity/test_digest.py @@ -7,7 +7,6 @@ from .support import check_url, start_server -# pylint: disable=inconsistent-return-statements # pylint: disable=missing-function-docstring # pylint: disable=redefined-outer-name # pylint: disable=no-self-use @@ -16,17 +15,19 @@ @fixture(scope="module") def url(request): """The URL (server fixture).""" - val = environ.get("TEST_DIGEST_URL", "").strip('/') + process = None + val = environ.get("TEST_DIGEST_URL", "").rstrip('/') if val: - return val - - process = start_server( - request, - join(dirname(__file__), pardir, 'examples/http_digest.py')) - - yield "http://localhost:8080" # server is running - process.kill() - process.wait() + yield val + else: + process = start_server( + request, + join(dirname(__file__), pardir, 'examples/http_digest.py')) + yield "http://localhost:8080" # server is running + + if process is not None: + process.kill() + process.wait() @fixture diff --git a/tests_integrity/test_json.py b/tests_integrity/test_json.py index 043dd46..bf1cb22 100644 --- a/tests_integrity/test_json.py +++ b/tests_integrity/test_json.py @@ -8,7 +8,6 @@ from . support import start_server, check_url # pylint: disable=missing-function-docstring -# pylint: disable=inconsistent-return-statements # pylint: disable=redefined-outer-name # pylint: disable=no-self-use # pylint: disable=consider-using-f-string @@ -17,17 +16,19 @@ @fixture(scope="module") def server(request): """Fixture for starting the JSON example server.""" - value = environ.get("TEST_SIMPLE_JSON_URL", "").strip('/') + process = None + value = environ.get("TEST_SIMPLE_JSON_URL", "").rstrip('/') if value: - return value - - process = start_server( - request, - join(dirname(__file__), pardir, 'examples/simple_json.py')) - - yield "http://localhost:8080" # server is running - process.kill() - process.wait() + yield value + else: + process = start_server( + request, + join(dirname(__file__), pardir, 'examples/simple_json.py')) + yield "http://localhost:8080" # server is running + + if process is not None: + process.kill() + process.wait() class TestHeaders: diff --git a/tests_integrity/test_metrics.py b/tests_integrity/test_metrics.py index 08445fb..1f513a2 100644 --- a/tests_integrity/test_metrics.py +++ b/tests_integrity/test_metrics.py @@ -15,18 +15,19 @@ def url(request): """Returns the server URL or starts the metrics application if it doesn't exist.""" - retval = environ.get("TEST_METRICS_URL", "").strip('/') + process = None + retval = environ.get("TEST_METRICS_URL", "").rstrip('/') if retval: yield retval - return - - process = start_server( - request, - join(dirname(__file__), pardir, 'examples/metrics.py')) - - yield "http://localhost:8080" # server is running - process.kill() - process.wait() + else: + process = start_server( + request, + join(dirname(__file__), pardir, 'examples/metrics.py')) + yield "http://localhost:8080" # server is running + + if process is not None: + process.kill() + process.wait() class TestMetrics(): diff --git a/tests_integrity/test_openapi.py b/tests_integrity/test_openapi.py index 501a9e0..294f89a 100644 --- a/tests_integrity/test_openapi.py +++ b/tests_integrity/test_openapi.py @@ -19,18 +19,19 @@ @fixture(scope="module") def url(request): """Fixture for starting the OpenAPI example server.""" - url = environ.get("TEST_OPENAPI_URL", "").strip('/') - if url: - yield url - return - - process = start_server( - request, - join(dirname(__file__), pardir, 'examples/openapi3.py')) - - yield "http://localhost:8080" # server is running - process.kill() - process.wait() + process = None + val = environ.get("TEST_OPENAPI_URL", "").rstrip('/') + if val: + yield val + else: + process = start_server( + request, + join(dirname(__file__), pardir, 'examples/openapi3.py')) + yield "http://localhost:8080" # server is running + + if process is not None: + process.kill() + process.wait() @fixture diff --git a/tests_integrity/test_profile.py b/tests_integrity/test_profile.py index 26a06dd..eda52d1 100644 --- a/tests_integrity/test_profile.py +++ b/tests_integrity/test_profile.py @@ -7,7 +7,6 @@ from . support import start_server, check_url # pylint: disable=missing-function-docstring -# pylint: disable=inconsistent-return-statements # pylint: disable=redefined-outer-name # pylint: disable=no-self-use # pylint: disable=consider-using-f-string @@ -17,18 +16,20 @@ @fixture(scope="module") def server(request): """Fixture for starting the profiling JSON example server.""" - value = environ.get("TEST_SIMPLE_JSON_URL", "").strip('/') + process = None + value = environ.get("TEST_SIMPLE_JSON_URL", "").rstrip('/') if value: - return value - - process = start_server( - request, - join(dirname(__file__), pardir, 'examples/simple_json.py'), - {"PROFILE": "1"}) - - yield "http://localhost:8080" # server is running - process.kill() - process.wait() + yield value + else: + process = start_server( + request, + join(dirname(__file__), pardir, 'examples/simple_json.py'), + {"PROFILE": "1"}) + yield "http://localhost:8080" # server is running + + if process is not None: + process.kill() + process.wait() class TestRequest: diff --git a/tests_integrity/test_session.py b/tests_integrity/test_session.py index 3cc40ff..9e53b95 100644 --- a/tests_integrity/test_session.py +++ b/tests_integrity/test_session.py @@ -7,7 +7,6 @@ from .support import check_url, start_server -# pylint: disable=inconsistent-return-statements # pylint: disable=missing-function-docstring # pylint: disable=no-self-use # pylint: disable=redefined-outer-name @@ -16,17 +15,19 @@ @fixture(scope="module") def url(request): """The URL (server fixture).""" - val = environ.get("TEST_SESSION_URL", "").strip('/') + process = None + val = environ.get("TEST_SESSION_URL", "").rstrip('/') if val: - return val - - process = start_server( - request, - join(dirname(__file__), pardir, 'examples/session.py')) - - yield "http://localhost:8080" # server is running - process.kill() - process.wait() + yield val + else: + process = start_server( + request, + join(dirname(__file__), pardir, 'examples/session.py')) + yield "http://localhost:8080" # server is running + + if process is not None: + process.kill() + process.wait() @fixture diff --git a/tests_integrity/test_simple.py b/tests_integrity/test_simple.py index fb104de..4e899ef 100644 --- a/tests_integrity/test_simple.py +++ b/tests_integrity/test_simple.py @@ -7,7 +7,6 @@ from .support import check_url, start_server -# pylint: disable=inconsistent-return-statements # pylint: disable=missing-function-docstring # pylint: disable=no-self-use # pylint: disable=redefined-outer-name @@ -17,17 +16,19 @@ @fixture(scope="module") def url(request): """The URL (server fixture).""" - url = environ.get("TEST_SIMPLE_URL", "").strip('/') - if url: - return url - - process = start_server( - request, - join(dirname(__file__), pardir, 'examples/simple.py')) - - yield "http://localhost:8080" # server is running - process.kill() - process.wait() + process = None + val = environ.get("TEST_SIMPLE_URL", "").rstrip('/') + if val: + yield val + else: + process = start_server( + request, + join(dirname(__file__), pardir, 'examples/simple.py')) + yield "http://localhost:8080" # server is running + + if process is not None: + process.kill() + process.wait() @fixture diff --git a/tests_integrity/test_websocket.py b/tests_integrity/test_websocket.py index 5427099..572159d 100644 --- a/tests_integrity/test_websocket.py +++ b/tests_integrity/test_websocket.py @@ -10,7 +10,6 @@ from . support import start_server, check_url -# pylint: disable=inconsistent-return-statements # pylint: disable=missing-function-docstring # pylint: disable=redefined-outer-name # pylint: disable=no-self-use @@ -19,18 +18,20 @@ @fixture(scope="module") def server(request): """Fixture for starting the WebSocket example server.""" - value = environ.get("TEST_WEBSOCKET_URL", "").strip('/') + process = None + value = environ.get("TEST_WEBSOCKET_URL", "").rstrip('/') if value: - return value + yield value + else: + process = start_server( + request, + join(dirname(__file__), pardir, 'examples/websocket.py'), + close=False) + yield "localhost:8080" # server is running - process = start_server( - request, - join(dirname(__file__), pardir, 'examples/websocket.py'), - close=False) - - yield "localhost:8080" # server is running - process.kill() - process.wait() + if process is not None: + process.kill() + process.wait() @fixture(scope="module")