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

Fixes tests to use the default project root config

Jean-Marc Martins 12 лет назад
Родитель
Сommit
33f09016fd
2 измененных файлов с 16 добавлено и 0 удалено
  1. 1 0
      radicale/config.py
  2. 15 0
      tests/__init__.py

+ 1 - 0
radicale/config.py

@@ -99,4 +99,5 @@ if "RADICALE_CONFIG" in os.environ:
     _CONFIG_PARSER.read(os.environ["RADICALE_CONFIG"])
 
 # Wrap config module into ConfigParser instance
+_CONFIG_PARSER.INITIAL_CONFIG = INITIAL_CONFIG
 sys.modules[__name__] = _CONFIG_PARSER

+ 15 - 0
tests/__init__.py

@@ -33,6 +33,11 @@ from io import BytesIO
 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
 
 import radicale
+
+RADICALE_CONFIG = os.path.join(os.path.dirname(os.path.dirname(__file__)),
+                               "config")
+os.environ["RADICALE_CONFIG"] = RADICALE_CONFIG
+
 from radicale import config
 from radicale.auth import htpasswd
 from radicale.storage import filesystem, database
@@ -45,6 +50,12 @@ class BaseTest(object):
     """Base class for tests."""
     def request(self, method, path, data=None, **args):
         """Send a request."""
+        # Create a ConfigParser and configure it
+        # This uses the default config file at the root of the
+        # Radicale Project
+        config.read(os.environ.get("RADICALE_CONFIG"))
+        self._CONFIG_PARSER = config
+
         self.application._status = None
         self.application._headers = None
         self.application._answer = None
@@ -69,6 +80,10 @@ class BaseTest(object):
         self.application._status = status
         self.application._headers = headers
 
+    @property
+    def config_instance(self):
+        return self._CONFIG_PARSER
+
 
 class FileSystem(BaseTest):
     """Base class for filesystem tests."""