diff --git a/client/configreader.py b/client/configreader.py index 79c5b47b..e1a2b69f 100644 --- a/client/configreader.py +++ b/client/configreader.py @@ -56,7 +56,7 @@ class ConfigReader(SafeConfigParserWithIncludes): def read(self, filename): basename = os.path.join(self._basedir, filename) - logSys.debug("Reading " + basename) + logSys.debug("Reading configs for %s under %s " % (basename, self._basedir)) config_files = [ basename + ".conf", basename + ".local" ] @@ -88,7 +88,7 @@ class ConfigReader(SafeConfigParserWithIncludes): return True else: logSys.error("Found no accessible config files for %r " % filename - + (["", + + (["under %s" % self.getBaseDir(), "among existing ones: " + ', '.join(config_files)][bool(len(config_files))])) return False diff --git a/testcases/clientreadertestcase.py b/testcases/clientreadertestcase.py index 55fb010d..389220ee 100644 --- a/testcases/clientreadertestcase.py +++ b/testcases/clientreadertestcase.py @@ -39,7 +39,6 @@ class ConfigReaderTest(unittest.TestCase): self.d = tempfile.mkdtemp(prefix="f2b-temp") self.c = ConfigReader(basedir=self.d) - def tearDown(self): """Call after every test case.""" shutil.rmtree(self.d) @@ -61,10 +60,19 @@ option = %s self.assertTrue(self.c.read('c')) # we still should have some - def _getoption(self): - self.assertTrue(self.c.read('c')) # we got some now + def _getoption(self, f='c'): + self.assertTrue(self.c.read(f)) # we got some now return self.c.getOptions('section', [("int", 'option')])['option'] + + def testInaccessibleFile(self): + f = os.path.join(self.d, "d.conf") # inaccessible file + self._write('d.conf', 0) + self.assertEqual(self._getoption('d'), 0) + os.chmod(f, 0) + self.assertFalse(self.c.read('d')) # should not be readable BUT present + + def testOptionalDotDDir(self): self.assertFalse(self.c.read('c')) # nothing is there yet self._write("c.conf", "1")