Tests: Replace gunicorn with waitress (works on Windows too)
This commit is contained in:
parent
941bb157cc
commit
9603aa3496
@ -38,11 +38,6 @@ from radicale import config, server
|
|||||||
from radicale.tests import BaseTest
|
from radicale.tests import BaseTest
|
||||||
from radicale.tests.helpers import configuration_to_dict, get_file_path
|
from radicale.tests.helpers import configuration_to_dict, get_file_path
|
||||||
|
|
||||||
try:
|
|
||||||
import gunicorn
|
|
||||||
except ImportError:
|
|
||||||
gunicorn = None
|
|
||||||
|
|
||||||
|
|
||||||
class DisabledRedirectHandler(request.HTTPRedirectHandler):
|
class DisabledRedirectHandler(request.HTTPRedirectHandler):
|
||||||
def http_error_302(self, req, fp, code, msg, headers):
|
def http_error_302(self, req, fp, code, msg, headers):
|
||||||
@ -174,7 +169,6 @@ class TestBaseServerRequests(BaseTest):
|
|||||||
if os.name == "posix":
|
if os.name == "posix":
|
||||||
assert p.returncode == 0
|
assert p.returncode == 0
|
||||||
|
|
||||||
@pytest.mark.skipif(not gunicorn, reason="gunicorn module not found")
|
|
||||||
def test_wsgi_server(self):
|
def test_wsgi_server(self):
|
||||||
config_path = os.path.join(self.colpath, "config")
|
config_path = os.path.join(self.colpath, "config")
|
||||||
parser = RawConfigParser()
|
parser = RawConfigParser()
|
||||||
@ -183,14 +177,13 @@ class TestBaseServerRequests(BaseTest):
|
|||||||
parser.write(f)
|
parser.write(f)
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env["PYTHONPATH"] = os.pathsep.join(sys.path)
|
env["PYTHONPATH"] = os.pathsep.join(sys.path)
|
||||||
|
env["RADICALE_CONFIG"] = config_path
|
||||||
p = subprocess.Popen([
|
p = subprocess.Popen([
|
||||||
sys.executable,
|
sys.executable, "-m", "waitress",
|
||||||
"-c", "from gunicorn.app.wsgiapp import run; run()",
|
"--listen", self.configuration.get_raw("server", "hosts"),
|
||||||
"--bind", self.configuration.get_raw("server", "hosts"),
|
"radicale:application"], env=env)
|
||||||
"--env", "RADICALE_CONFIG=%s" % config_path, "radicale"], env=env)
|
|
||||||
try:
|
try:
|
||||||
self.get("/", is_alive_fn=lambda: p.poll() is None, check=302)
|
self.get("/", is_alive_fn=lambda: p.poll() is None, check=302)
|
||||||
finally:
|
finally:
|
||||||
p.terminate()
|
p.terminate()
|
||||||
p.wait()
|
p.wait()
|
||||||
assert p.returncode == 0
|
|
||||||
|
5
setup.py
5
setup.py
@ -36,7 +36,6 @@ For further information, please visit the `Radicale Website
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
@ -53,9 +52,7 @@ WEB_FILES = ["web/internal_data/css/icon.png",
|
|||||||
needs_pytest = {"pytest", "test", "ptr"}.intersection(sys.argv)
|
needs_pytest = {"pytest", "test", "ptr"}.intersection(sys.argv)
|
||||||
pytest_runner = ["pytest-runner"] if needs_pytest else []
|
pytest_runner = ["pytest-runner"] if needs_pytest else []
|
||||||
tests_require = ["pytest-runner", "pytest", "pytest-cov", "pytest-flake8",
|
tests_require = ["pytest-runner", "pytest", "pytest-cov", "pytest-flake8",
|
||||||
"pytest-isort"]
|
"pytest-isort", "waitress"]
|
||||||
if os.name == "posix":
|
|
||||||
tests_require.append("gunicorn")
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="Radicale",
|
name="Radicale",
|
||||||
|
Loading…
Reference in New Issue
Block a user