Skip to content

Commit

Permalink
We wanted to confirm more strictly we're dealing with a traceback here.
Browse files Browse the repository at this point in the history
However, doctest will preprocess exception output. It gets rid of the
the stack trace and the "Traceback (most recent call last)"-part. It
passes only the exception message to the checker.
  • Loading branch information
janwijbrand committed Sep 30, 2016
1 parent e5f4996 commit 08aa3d5
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/zope/testing/renormalizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#
##############################################################################
import sys
import re
import doctest


Expand Down Expand Up @@ -99,18 +98,15 @@ 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):
# We wanted to confirm more strictly we're dealing with a traceback here.
# However, doctest will preprocess exception output. It gets rid of the
# the stack trace and the "Traceback (most recent call last)"-part. It
# passes only the exception message to the checker.
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 Down

0 comments on commit 08aa3d5

Please sign in to comment.