BF: (python 2.[45]) store backends names in a list to use .index later on (Closes gh-83)

.index() got into tuple's API only in 2.6
pull/68/merge
Yaroslav Halchenko 2012-11-01 15:34:20 -04:00
parent 9510619b7b
commit 5becaf8ef2
3 changed files with 12 additions and 1 deletions

View File

@ -125,6 +125,7 @@ tests.addTest(unittest.makeSuite(filtertestcase.LogFile))
tests.addTest(unittest.makeSuite(filtertestcase.LogFileMonitor))
tests.addTest(unittest.makeSuite(filtertestcase.GetFailures))
tests.addTest(unittest.makeSuite(filtertestcase.DNSUtilsTests))
tests.addTest(unittest.makeSuite(filtertestcase.JailTests))
# DateDetector
tests.addTest(unittest.makeSuite(datedetectortestcase.DateDetectorTest))

View File

@ -33,7 +33,9 @@ logSys = logging.getLogger("fail2ban.jail")
class Jail:
#Known backends. Each backend should have corresponding __initBackend method
_BACKENDS = ('pyinotify', 'gamin', 'polling')
# yoh: stored in a list instead of a tuple since only
# list had .index until 2.6
_BACKENDS = ['pyinotify', 'gamin', 'polling']
def __init__(self, name, backend = "auto"):
self.__name = name

View File

@ -28,6 +28,7 @@ import sys
import time
import tempfile
from server.jail import Jail
from server.filterpoll import FilterPoll
from server.filter import FileFilter, DNSUtils
from server.failmanager import FailManager
@ -626,3 +627,10 @@ class DNSUtilsTests(unittest.TestCase):
self.assertEqual(res, ['192.0.43.10'])
else:
self.assertEqual(res, [])
class JailTests(unittest.TestCase):
def testSetBackend_gh83(self):
# smoke test
jail = Jail('test', backend='polling') # Must not fail to initiate