mirror of https://github.com/fail2ban/fail2ban
Merge branch '0.11'
commit
80a33b1dee
|
@ -188,6 +188,7 @@ def _assert_correct_last_attempt(utest, filter_, output, count=None):
|
|||
utest.assertEqual(len(found), 1)
|
||||
_assert_equal_entries(utest, found[0], output, count)
|
||||
else:
|
||||
utest.assertEqual(len(found), len(output))
|
||||
# sort by string representation of ip (multiple failures with different ips):
|
||||
found = sorted(found, key=lambda x: str(x))
|
||||
output = sorted(output, key=lambda x: str(x))
|
||||
|
|
|
@ -66,9 +66,12 @@ class TestServer(Server):
|
|||
|
||||
class TransmitterBase(LogCaptureTestCase):
|
||||
|
||||
TEST_SRV_CLASS = TestServer
|
||||
|
||||
def setUp(self):
|
||||
"""Call before every test case."""
|
||||
super(TransmitterBase, self).setUp()
|
||||
self.server = self.TEST_SRV_CLASS()
|
||||
self.transm = self.server._Server__transm
|
||||
# To test thransmitter we don't need to start server...
|
||||
#self.server.start('/dev/null', '/dev/null', force=False)
|
||||
|
@ -157,10 +160,6 @@ class TransmitterBase(LogCaptureTestCase):
|
|||
|
||||
class Transmitter(TransmitterBase):
|
||||
|
||||
def setUp(self):
|
||||
self.server = TestServer()
|
||||
super(Transmitter, self).setUp()
|
||||
|
||||
def testServerIsNotStarted(self):
|
||||
# so far isStarted only tested but not used otherwise
|
||||
# and here we don't really .start server
|
||||
|
@ -937,8 +936,9 @@ class Transmitter(TransmitterBase):
|
|||
|
||||
class TransmitterLogging(TransmitterBase):
|
||||
|
||||
TEST_SRV_CLASS = Server
|
||||
|
||||
def setUp(self):
|
||||
self.server = Server()
|
||||
super(TransmitterLogging, self).setUp()
|
||||
self.server.setLogTarget("/dev/null")
|
||||
self.server.setLogLevel("CRITICAL")
|
||||
|
|
|
@ -47,7 +47,7 @@ from ..server import asyncserver
|
|||
from ..version import version
|
||||
|
||||
|
||||
logSys = getLogger(__name__)
|
||||
logSys = getLogger("fail2ban")
|
||||
|
||||
TEST_NOW = 1124013600
|
||||
|
||||
|
@ -126,9 +126,6 @@ def getOptParser(doc=""):
|
|||
|
||||
def initProcess(opts):
|
||||
# Logger:
|
||||
global logSys
|
||||
logSys = getLogger("fail2ban")
|
||||
|
||||
llev = None
|
||||
if opts.log_level is not None: # pragma: no cover
|
||||
# so we had explicit settings
|
||||
|
@ -782,8 +779,9 @@ class LogCaptureTestCase(unittest.TestCase):
|
|||
"""Call after every test case."""
|
||||
# print "O: >>%s<<" % self._log.getvalue()
|
||||
self.pruneLog()
|
||||
self._log.close()
|
||||
logSys.handlers = self._old_handlers
|
||||
logSys.level = self._old_level
|
||||
logSys.setLevel(self._old_level)
|
||||
super(LogCaptureTestCase, self).tearDown()
|
||||
|
||||
def _is_logged(self, *s, **kwargs):
|
||||
|
|
Loading…
Reference in New Issue