ENH: FilterReader - use the set methods (improve coverage), test getters, use os.path.join

pull/522/head
Yaroslav Halchenko 2013-12-27 01:43:23 -05:00
parent 0141a6dbe7
commit 4e165c9692
2 changed files with 10 additions and 4 deletions

View File

@ -24,6 +24,7 @@ __author__ = "Cyril Jaquier"
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
__license__ = "GPL"
import os
import logging
from configreader import ConfigReader
@ -34,11 +35,14 @@ class FilterReader(ConfigReader):
def __init__(self, fileName, name, **kwargs):
ConfigReader.__init__(self, **kwargs)
self.__file = fileName
self.__name = name
# Defer initialization to the set Methods
self.__file = self.__name = self.__opts = None
self.setFile(fileName)
self.setName(name)
def setFile(self, fileName):
self.__file = fileName
self.__opts = None
def getFile(self):
return self.__file
@ -50,7 +54,7 @@ class FilterReader(ConfigReader):
return self.__name
def read(self):
return ConfigReader.read(self, "filter.d/" + self.__file)
return ConfigReader.read(self, os.path.join("filter.d", self.__file))
def getOptions(self, pOpts):
opts = [["string", "ignoreregex", ""],

View File

@ -60,6 +60,8 @@ def testSampleRegexsFactory(name):
# Check filter exists
filterConf = FilterReader(name, "jail", basedir=CONFIG_DIR)
self.assertEqual(filterConf.getFile(), name)
self.assertEqual(filterConf.getName(), "jail")
filterConf.read()
filterConf.getOptions({})