From ab044b75ea0ad89e44ae075d24162ff9d5c07284 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Wed, 27 Mar 2013 12:22:39 -0400 Subject: [PATCH] BF: delay check for the existence of config directory until read() --- client/configreader.py | 6 +++--- testcases/clientreadertestcase.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/configreader.py b/client/configreader.py index 9028df48..243c843c 100644 --- a/client/configreader.py +++ b/client/configreader.py @@ -46,15 +46,15 @@ class ConfigReader(SafeConfigParserWithIncludes): def setBaseDir(self, basedir): if basedir is None: basedir = ConfigReader.DEFAULT_BASEDIR # stock system location - if not (os.path.exists(basedir) and os.access(basedir, os.R_OK | os.X_OK)): - raise ValueError("Base configuration directory %s either does not exist " - "or is not accessible" % basedir) self._basedir = basedir.rstrip('/') def getBaseDir(self): return self._basedir def read(self, filename): + if not (os.path.exists(self._basedir) and os.access(self._basedir, os.R_OK | os.X_OK)): + raise ValueError("Base configuration directory %s either does not exist " + "or is not accessible" % self._basedir) basename = os.path.join(self._basedir, filename) logSys.debug("Reading configs for %s under %s " % (basename, self._basedir)) config_files = [ basename + ".conf", diff --git a/testcases/clientreadertestcase.py b/testcases/clientreadertestcase.py index 3e606785..fad16f04 100644 --- a/testcases/clientreadertestcase.py +++ b/testcases/clientreadertestcase.py @@ -114,7 +114,8 @@ class JailsReaderTest(unittest.TestCase): def testProvidingBadBasedir(self): if not os.path.exists('/XXX'): - self.assertRaises(ValueError, JailsReader, basedir='/XXX') + reader = JailsReader(basedir='/XXX') + self.assertRaises(ValueError, reader.read) def testReadStockJailConf(self): jails = JailsReader(basedir='config') # we are running tests from root project dir atm