'Assert that L{printDetailedTraceback} produces and prints a detailed
traceback.
The detailed traceback consists of a header::
*--- Failure #20 ---
The body contains the stacktrace::
/twisted/trial/_synctest.py:1180: _run(...)
/twisted/python/util.py:1076: runWithWarningsSuppressed(...)
--- <exception caught here> ---
/twisted/test/test_failure.py:39: getDivisionFailure(...)
If C{captureVars} is enabled the body also includes a list of
globals and locals::
[ Locals ]
exampleLocalVar : \'xyz\'
( Globals )
Or when C{captureVars} is disabled::
[Capture of Locals and Globals disabled (use captureVars=True)]
When C{cleanFailure} is enabled references to other objects are removed
and replaced with strings.
And finally the footer with the L{Failure}\'s value::
exceptions.ZeroDivisionError: float division
*--- End of Failure #20 ---
@param captureVars: Enables L{Failure.captureVars}.
@type captureVars: C{bool}
@param cleanFailure: Enables L{Failure.cleanFailure}.
@type cleanFailure: C{bool}'

def assertDetailedTraceback(self, captureVars=False, cleanFailure=False):

    if captureVars:
        exampleLocalVar = 'xyz'
        exampleLocalVar
    f = getDivisionFailure(captureVars=captureVars)
    out = NativeStringIO()
    if cleanFailure:
        f.cleanFailure()
    f.printDetailedTraceback(out)
    tb = out.getvalue()
    start = ('*---    Failure    #%d%s---\n' % (f.count, ((f.pickled and '    (pickled)    ') or '    ')))
    end = ('%s:    %s\n*---    End    of    Failure    #%s    ---\n' % (reflect.qual(f.type), reflect.safe_str(f.value), f.count))
    self.assertTracebackFormat(tb, start, end)
    linesWithVars = [line for line in tb.splitlines() if line.startswith('        ')]
    if captureVars:
        self.assertNotEqual([], linesWithVars)
        if cleanFailure:
            line = '        exampleLocalVar    :    "\'xyz\'"'
        else:
            line = "        exampleLocalVar    :    'xyz'"
        self.assertIn(line, linesWithVars)
    else:
        self.assertEqual([], linesWithVars)
        self.assertIn('    [Capture    of    Locals    and    Globals    disabled    (use    captureVars=True)]\n', tb)
