root/galaxy-central/eggs/nose-0.11.1-py2.6.egg/nose/plugins/failuredetail.py @ 3

リビジョン 3, 1.4 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1"""
2This plugin provides assert introspection. When the plugin is enabled
3and a test failure occurs, the traceback is displayed with extra context
4around the line in which the exception was raised. Simple variable
5substitution is also performed in the context output to provide more
6debugging information.
7"""
8   
9from nose.plugins import Plugin
10from nose.inspector import inspect_traceback
11
12class FailureDetail(Plugin):
13    """
14    Plugin that provides extra information in tracebacks of test failures.
15    """
16    score = 600 # before capture
17   
18    def options(self, parser, env):
19        """Register commmandline options.
20        """
21        parser.add_option(
22            "-d", "--detailed-errors", "--failure-detail",
23            action="store_true",
24            default=env.get('NOSE_DETAILED_ERRORS'),
25            dest="detailedErrors", help="Add detail to error"
26            " output by attempting to evaluate failed"
27            " asserts [NOSE_DETAILED_ERRORS]")
28
29    def configure(self, options, conf):
30        """Configure plugin.
31        """
32        if not self.can_configure:
33            return
34        self.enabled = options.detailedErrors
35        self.conf = conf
36
37    def formatFailure(self, test, err):
38        """Add detail from traceback inspection to error message of a failure.
39        """
40        ec, ev, tb = err
41        tbinfo = inspect_traceback(tb)
42        test.tbinfo = tbinfo
43        return (ec, '\n'.join([str(ev), tbinfo]), tb)
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。