"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "fail2ban/tests/filtertestcase.py" between
fail2ban-0.10.5.tar.gz and fail2ban-0.11.1.tar.gz

About:

filtertestcase.py  (fail2ban-0.10.5):filtertestcase.py  (fail2ban-0.11.1)
skipping to change at line 93 skipping to change at line 93
_maxWaitTime = unittest.F2B.maxWaitTime _maxWaitTime = unittest.F2B.maxWaitTime
class _tmSerial(): class _tmSerial():
_last_s = -0x7fffffff _last_s = -0x7fffffff
_last_m = -0x7fffffff _last_m = -0x7fffffff
_str_s = "" _str_s = ""
_str_m = "" _str_m = ""
@staticmethod @staticmethod
def _tm(time): def _tm(time):
# ## strftime it too slow for large time serializer : # ## strftime it too slow for large time serializer :
# return datetime.datetime.fromtimestamp(time).strftime("%Y-%m-%d %H:%M:%S") # return MyTime.time2str(time)
c = _tmSerial c = _tmSerial
sec = (time % 60) sec = (time % 60)
if c._last_s == time - sec: if c._last_s == time - sec:
return "%s%02u" % (c._str_s, sec) return "%s%02u" % (c._str_s, sec)
mt = (time % 3600) mt = (time % 3600)
if c._last_m == time - mt: if c._last_m == time - mt:
c._last_s = time - sec c._last_s = time - sec
c._str_s = "%s%02u:" % (c._str_m, mt // 60) c._str_s = "%s%02u:" % (c._str_m, mt // 60)
return "%s%02u" % (c._str_s, sec) return "%s%02u" % (c._str_s, sec)
c._last_m = time - mt c._last_m = time - mt
skipping to change at line 299 skipping to change at line 299
lambda: _assert_equal_entries(self, lambda: _assert_equal_entries(self,
('1.1.1.1', 1, 1421262060.0), ('1.1.1.1', 1, 1421262060.0),
('1.1.1.1', 1, 1421262059.0), ('1.1.1.1', 1, 1421262059.0),
1) 1)
) )
def testTest_tm(self): def testTest_tm(self):
unittest.F2B.SkipIfFast() unittest.F2B.SkipIfFast()
## test function "_tm" works correct (returns the same as slow st rftime): ## test function "_tm" works correct (returns the same as slow st rftime):
for i in xrange(1417512352, (1417512352 // 3600 + 3) * 3600): for i in xrange(1417512352, (1417512352 // 3600 + 3) * 3600):
tm = datetime.datetime.fromtimestamp(i).strftime("%Y-%m-% d %H:%M:%S") tm = MyTime.time2str(i)
if _tm(i) != tm: # pragma: no cover - never reachable if _tm(i) != tm: # pragma: no cover - never reachable
self.assertEqual((_tm(i), i), (tm, i)) self.assertEqual((_tm(i), i), (tm, i))
def testWrongCharInTupleLine(self): def testWrongCharInTupleLine(self):
## line tuple has different types (ascii after ascii / unicode): ## line tuple has different types (ascii after ascii / unicode):
for a1 in ('', u'', b''): for a1 in ('', u'', b''):
for a2 in ('2016-09-05T20:18:56', u'2016-09-05T20:18:56', b'2016-09-05T20:18:56'): for a2 in ('2016-09-05T20:18:56', u'2016-09-05T20:18:56', b'2016-09-05T20:18:56'):
for a3 in ( for a3 in (
'Fail for "g\xc3\xb6ran" from 192.0.2.1', 'Fail for "g\xc3\xb6ran" from 192.0.2.1',
u'Fail for "g\xc3\xb6ran" from 192.0.2.1' , u'Fail for "g\xc3\xb6ran" from 192.0.2.1' ,
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)