Sfoglia il codice sorgente

Tests: Use absolute imports

Unrud 6 anni fa
parent
commit
ed72e697de

+ 0 - 2
radicale/tests/__init__.py

@@ -48,8 +48,6 @@ def finish_request_cov(self, request, client_address):
 
 server.ParallelHTTPServer.finish_request = finish_request_cov
 
-# Allow importing of tests.custom....
-sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
 # Enable debug output
 radicale.log.logger.setLevel(logging.DEBUG)
 

+ 2 - 3
radicale/tests/test_auth.py

@@ -29,8 +29,7 @@ import tempfile
 import pytest
 
 from radicale import Application, config
-
-from .test_base import BaseTest
+from radicale.tests.test_base import BaseTest
 
 
 class TestBaseAuthRequests(BaseTest):
@@ -162,7 +161,7 @@ class TestBaseAuthRequests(BaseTest):
     def test_custom(self):
         """Custom authentication."""
         self.configuration.update(
-            {"auth": {"type": "tests.custom.auth"}}, "test")
+            {"auth": {"type": "radicale.tests.custom.auth"}}, "test")
         self.application = Application(self.configuration)
         status, _, answer = self.request(
             "PROPFIND", "/tmp", HTTP_AUTHORIZATION="Basic %s" %

+ 3 - 4
radicale/tests/test_base.py

@@ -32,9 +32,8 @@ from functools import partial
 import pytest
 
 from radicale import Application, config, storage
-
-from . import BaseTest
-from .helpers import get_file_content
+from radicale.tests import BaseTest
+from radicale.tests.helpers import get_file_content
 
 
 class BaseRequestsMixIn:
@@ -1632,7 +1631,7 @@ class TestMultiFileSystem(BaseFileSystemTest, BaseRequestsMixIn):
 
 class TestCustomStorageSystem(BaseFileSystemTest):
     """Test custom backend loading."""
-    storage_type = "tests.custom.storage_simple_sync"
+    storage_type = "radicale.tests.custom.storage_simple_sync"
     full_sync_token_support = False
     _report_sync_token = BaseRequestsMixIn._report_sync_token
     test_root = BaseRequestsMixIn.test_root

+ 1 - 2
radicale/tests/test_config.py

@@ -22,8 +22,7 @@ from configparser import RawConfigParser
 import pytest
 
 from radicale import config
-
-from .helpers import configuration_to_dict
+from radicale.tests.helpers import configuration_to_dict
 
 
 class TestConfig:

+ 4 - 5
radicale/tests/test_rights.py

@@ -24,9 +24,8 @@ import shutil
 import tempfile
 
 from radicale import Application, config
-
-from .helpers import get_file_content
-from .test_base import BaseTest
+from radicale.tests.helpers import get_file_content
+from radicale.tests.test_base import BaseTest
 
 
 class TestBaseRightsRequests(BaseTest):
@@ -144,8 +143,8 @@ permissions: Rr""")
 
     def test_custom(self):
         """Custom rights management."""
-        self._test_rights("tests.custom.rights", "", "/", "r", 401)
-        self._test_rights("tests.custom.rights", "", "/tmp", "r", 207)
+        self._test_rights("radicale.tests.custom.rights", "", "/", "r", 401)
+        self._test_rights("radicale.tests.custom.rights", "", "/tmp", "r", 207)
 
     def test_collections_and_items(self):
         """Test rights for creation of collections, calendars and items.

+ 1 - 2
radicale/tests/test_server.py

@@ -35,8 +35,7 @@ from urllib.error import HTTPError, URLError
 import pytest
 
 from radicale import config, server
-
-from .helpers import configuration_to_dict, get_file_path
+from radicale.tests.helpers import configuration_to_dict, get_file_path
 
 try:
     import gunicorn

+ 2 - 3
radicale/tests/test_web.py

@@ -23,8 +23,7 @@ import shutil
 import tempfile
 
 from radicale import Application, config
-
-from .test_base import BaseTest
+from radicale.tests.test_base import BaseTest
 
 
 class TestBaseWebRequests(BaseTest):
@@ -62,7 +61,7 @@ class TestBaseWebRequests(BaseTest):
     def test_custom(self):
         """Custom web plugin."""
         self.configuration.update({
-            "web": {"type": "tests.custom.web"}}, "test")
+            "web": {"type": "radicale.tests.custom.web"}}, "test")
         self.application = Application(self.configuration)
         status, _, answer = self.request("GET", "/.web")
         assert status == 200