From 396e0a3644b4f1796af8f79485c543e6929f0098 Mon Sep 17 00:00:00 2001 From: Henrik Skupin Date: Wed, 12 Jun 2024 09:17:23 +0200 Subject: [PATCH] Use httpd fixture per session to increase test runtime drasticallly (#690) --- pytest.ini | 4 +++- tests/conftest.py | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pytest.ini b/pytest.ini index 85ce36cc..98726bc5 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,6 @@ [pytest] +addopts = -vv --durations=5 +log_cli = 1 markers = ci_only: Only run these tests within the CI environment. - + diff --git a/tests/conftest.py b/tests/conftest.py index fad373f8..18dd4436 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,8 +1,6 @@ -import base64 import os import pytest -from urllib.parse import parse_qs, urlparse from wptserve import ( handlers, @@ -34,19 +32,22 @@ def basic_auth_handler(req, response): response.content = content.format("restricted") -@pytest.fixture +@pytest.fixture(scope="session") def httpd(): HERE = os.path.dirname(os.path.abspath(__file__)) + routes = [ ("GET", "/basic_auth", basic_auth_handler), ] routes.extend(default_routes.routes) + httpd = server.WebTestHttpd( host="127.0.0.1", port=0, doc_root=os.path.join(HERE, 'data'), routes=routes, ) + httpd.start() yield httpd httpd.stop()