/usr/lib/python2.7/dist-packages/zope/exceptions/tests/test_log.py is in python-zope.exceptions 4.0.7-1.
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 60 | ##############################################################################
#
# Copyright (c) 2012 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.
#
##############################################################################
"""log.Formatter tests.
"""
import unittest
class FormatterTests(unittest.TestCase):
def _getTargetClass(self):
from zope.exceptions.log import Formatter
return Formatter
def _makeOne(self, *args, **kw):
return self._getTargetClass()(*args, **kw)
def test_simple_exception(self):
import traceback
tb = DummyTB()
tb.tb_frame = DummyFrame()
exc = ValueError('testing')
fmt = self._makeOne()
result = fmt.formatException((ValueError, exc, tb))
lines = result.splitlines()
self.assertEqual(len(lines), 3)
self.assertEqual(lines[0], 'Traceback (most recent call last):')
self.assertEqual(lines[1], ' File "dummy/filename.py", line 14, '
'in dummy_function')
self.assertEqual(lines[2],
traceback.format_exception_only(
ValueError, exc)[0][:-1]) #trailing \n
class DummyTB(object):
tb_lineno = 14
tb_next = None
class DummyFrame(object):
f_lineno = 137
f_back = None
def __init__(self):
self.f_locals = {}
self.f_globals = {}
self.f_code = DummyCode()
class DummyCode(object):
co_filename = 'dummy/filename.py'
co_name = 'dummy_function'
|