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
pull/225/head
Yaroslav Halchenko 2013-05-10 00:02:49 -04:00
parent dc05eee0f5
commit 281d310b7e
2 changed files with 6 additions and 5 deletions

View File

@ -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)

View File

@ -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]: