'Explicitly call dump_traceback() function and check its output.
Raise an error if the output doesn\'t match the expected format.'

def check_dump_traceback(self, filename):

    code = '\n                                                import    faulthandler\n\n                                                def    funcB():\n                                                                if    {has_filename}:\n                                                                                with    open({filename},    "wb")    as    fp:\n                                                                                                faulthandler.dump_traceback(fp,    all_threads=False)\n                                                                else:\n                                                                                faulthandler.dump_traceback(all_threads=False)\n\n                                                def    funcA():\n                                                                funcB()\n\n                                                funcA()\n                                                '
    code = code.format(filename=repr(filename), has_filename=bool(filename))
    if filename:
        lineno = 6
    else:
        lineno = 8
    expected = ['Stack    (most    recent    call    first):', ('        File    "<string>",    line    %s    in    funcB' % lineno), '        File    "<string>",    line    11    in    funcA', '        File    "<string>",    line    13    in    <module>']
    (trace, exitcode) = self.get_output(code, filename)
    self.assertEqual(trace, expected)
    self.assertEqual(exitcode, 0)
