mirror of
https://github.com/fail2ban/fail2ban.git
synced 2026-07-11 01:53:05 +00:00
ENH: actually tune up TraceBack to determine "unittest" portions of the stack across all python releases
before for 2.7 it would spit out "suite" and other components of unittest module
This commit is contained in:
parent
dc05eee0f5
commit
281d310b7e
2 changed files with 6 additions and 5 deletions
|
|
@ -108,7 +108,7 @@ class TestsUtilsTest(unittest.TestCase):
|
|||
print deep_function(3)
|
||||
except ValueError:
|
||||
s = tb()
|
||||
self.assertTrue('>' in s)
|
||||
self.assertFalse('>' in s) # There is only "fail2ban-testcases" in this case, no true traceback
|
||||
self.assertTrue(':' in s)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -61,11 +61,12 @@ class TraceBack(object):
|
|||
|
||||
def __call__(self):
|
||||
ftb = traceback.extract_stack(limit=100)[:-2]
|
||||
entries = [[mbasename(x[0]), str(x[1])] for x in ftb]
|
||||
entries = [ e for e in entries
|
||||
if not e[0] in ['unittest', 'logging.__init__' ]]
|
||||
entries = [[mbasename(x[0]), dirname(x[0]), str(x[1])] for x in ftb]
|
||||
entries = [ [e[0], e[2]] for e in entries
|
||||
if not (e[0] in ['unittest', 'logging.__init__']
|
||||
or e[1].endswith('/unittest'))]
|
||||
|
||||
# lets make it more consize
|
||||
# lets make it more concise
|
||||
entries_out = [entries[0]]
|
||||
for entry in entries[1:]:
|
||||
if entry[0] == entries_out[-1][0]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue