/usr/lib/python2.7/dist-packages/zope/testrunner/debug.py is in python-zope.testrunner 4.4.2-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | ##############################################################################
#
# Copyright (c) 2004-2008 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Debug functions
"""
from __future__ import print_function
import doctest
import sys
import pdb
import traceback
import zope.testrunner.interfaces
def post_mortem(exc_info):
err = exc_info[1]
if isinstance(err, (doctest.UnexpectedException, doctest.DocTestFailure)):
if isinstance(err, doctest.UnexpectedException):
exc_info = err.exc_info
# Print out location info if the error was in a doctest
if exc_info[2].tb_frame.f_code.co_filename == '<string>':
print_doctest_location(err)
else:
print_doctest_location(err)
# Hm, we have a DocTestFailure exception. We need to
# generate our own traceback
try:
exec(('raise ValueError'
'("Expected and actual output are different")'
), err.test.globs)
except:
exc_info = sys.exc_info()
print(''.join(traceback.format_exception_only(exc_info[0], exc_info[1])))
pdb.post_mortem(exc_info[2])
raise zope.testrunner.interfaces.EndRun()
def print_doctest_location(err):
# This mimics pdb's output, which gives way cool results in emacs :)
filename = err.test.filename
if filename.endswith('.pyc'):
filename = filename[:-1]
print("> %s(%s)_()" % (filename, err.test.lineno+err.example.lineno+1))
|