Skip to content

Commit

Permalink
be more strict about how the traceback output should look like.
Browse files Browse the repository at this point in the history
  • Loading branch information
janwijbrand committed Sep 30, 2016
1 parent ec65384 commit 8d1a396
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/zope/testing/renormalizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#
##############################################################################
import sys
import re
import doctest


Expand Down Expand Up @@ -96,11 +97,18 @@ def output_difference(self, example, got, optionflags):
RENormalizing = OutputChecker


_TRACEBACK_RE = re.compile(
r"Traceback \((most recent call last|innermost last)\):")


def maybe_a_traceback(string):
if not string:
return None

lines = string.splitlines()
if not _TRACEBACK_RE.match(lines[0]):
return None

last = lines[-1]
words = last.split(' ')
first = words[0]
Expand All @@ -111,8 +119,6 @@ def maybe_a_traceback(string):


def strip_dottedname_from_traceback(string):
# We might want to confirm more strictly were dealing with a traceback.
# We'll assume so for now.
maybe = maybe_a_traceback(string)
if maybe is None:
return string
Expand Down

0 comments on commit 8d1a396

Please sign in to comment.