Просмотр исходного кода

Tests: Replace gunicorn with waitress (works on Windows too)

Unrud 6 лет назад
Родитель
Сommit
9603aa3496
2 измененных файлов с 5 добавлено и 15 удалено
  1. 4 11
      radicale/tests/test_server.py
  2. 1 4
      setup.py

+ 4 - 11
radicale/tests/test_server.py

@@ -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,
-            "-c", "from gunicorn.app.wsgiapp import run; run()",
-            "--bind", self.configuration.get_raw("server", "hosts"),
-            "--env", "RADICALE_CONFIG=%s" % config_path, "radicale"], env=env)
+            sys.executable, "-m", "waitress",
+            "--listen", self.configuration.get_raw("server", "hosts"),
+            "radicale:application"], 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

+ 1 - 4
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"]
-if os.name == "posix":
-    tests_require.append("gunicorn")
+                 "pytest-isort", "waitress"]
 
 
 setup(
 setup(
     name="Radicale",
     name="Radicale",