From 33f09016fdb43351a0d2908098f6ef4a9763ceaf Mon Sep 17 00:00:00 2001 From: Jean-Marc Martins Date: Mon, 9 Sep 2013 15:36:30 +0200 Subject: [PATCH 1/2] Fixes tests to use the default project root config --- radicale/config.py | 1 + tests/__init__.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/radicale/config.py b/radicale/config.py index 44d057ec..47f6544d 100644 --- a/radicale/config.py +++ b/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 diff --git a/tests/__init__.py b/tests/__init__.py index ec5a84da..14ef5f62 100644 --- a/tests/__init__.py +++ b/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.""" From d8f686a497aefb7b9f5c7dc16fd54a06054721e0 Mon Sep 17 00:00:00 2001 From: Jean-Marc Martins Date: Mon, 9 Sep 2013 17:00:04 +0200 Subject: [PATCH 2/2] Fixed stupid redundancy in tests --- radicale/config.py | 1 - tests/__init__.py | 15 ++------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/radicale/config.py b/radicale/config.py index 47f6544d..44d057ec 100644 --- a/radicale/config.py +++ b/radicale/config.py @@ -99,5 +99,4 @@ 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 diff --git a/tests/__init__.py b/tests/__init__.py index 14ef5f62..b5bd194c 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -34,9 +34,8 @@ 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 +os.environ["RADICALE_CONFIG"] = os.path.join(os.path.dirname( + os.path.dirname(__file__)), "config") from radicale import config from radicale.auth import htpasswd @@ -50,12 +49,6 @@ 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 @@ -80,10 +73,6 @@ 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."""