예제 #1
0
    def test_manyFrames(self):
        """
        A C{_Traceback} object constructed with multiple frames should be able
        to be passed to L{traceback.extract_tb}, and we should get a list
        containing a tuple for each frame.
        """
        tb = failure._Traceback(
            [
                ["caller1", "filename.py", 7, {}, {}],
                ["caller2", "filename.py", 8, {}, {}],
            ],
            [
                ["method1", "filename.py", 123, {}, {}],
                ["method2", "filename.py", 235, {}, {}],
            ],
        )
        self.assertEqual(
            traceback.extract_tb(tb),
            [
                _tb("filename.py", 123, "method1", None),
                _tb("filename.py", 235, "method2", None),
            ],
        )

        # We should also be able to extract_stack on it
        self.assertEqual(
            traceback.extract_stack(tb.tb_frame),
            [
                _tb("filename.py", 7, "caller1", None),
                _tb("filename.py", 8, "caller2", None),
                _tb("filename.py", 123, "method1", None),
            ],
        )
예제 #2
0
 def test_manyFrames(self):
     """
     A C{_Traceback} object constructed with multiple frames should be able
     to be passed to L{traceback.extract_tb}, and we should get a list
     containing a tuple for each frame.
     """
     tb = failure._Traceback([["method1", "filename.py", 123, {}, {}], ["method2", "filename.py", 235, {}, {}]])
     self.assertEqual(
         traceback.extract_tb(tb), [("filename.py", 123, "method1", None), ("filename.py", 235, "method2", None)]
     )
예제 #3
0
 def test_manyFrames(self):
     """
     A C{_Traceback} object constructed with multiple frames should be able
     to be passed to L{traceback.extract_tb}, and we should get a list
     containing a tuple for each frame.
     """
     tb = failure._Traceback([['method1', 'filename.py', 123, {}, {}],
                              ['method2', 'filename.py', 235, {}, {}]])
     self.assertEqual(traceback.extract_tb(tb),
                      [('filename.py', 123, 'method1', None),
                       ('filename.py', 235, 'method2', None)])
 def test_singleFrame(self):
     """
     A C{_Traceback} object constructed with a single frame should be able
     to be passed to L{traceback.extract_tb}, and we should get a singleton
     list containing a (filename, lineno, methodname, line) tuple.
     """
     tb = failure._Traceback([["method", "filename.py", 123, {}, {}]])
     # Note that we don't need to test that extract_tb correctly extracts
     # the line's contents. In this case, since filename.py doesn't exist,
     # it will just use None.
     self.assertEqual(traceback.extract_tb(tb), [_tb("filename.py", 123, "method", None)])
예제 #5
0
 def test_singleFrame(self):
     """
     A C{_Traceback} object constructed with a single frame should be able
     to be passed to L{traceback.extract_tb}, and we should get a singleton
     list containing a (filename, lineno, methodname, line) tuple.
     """
     tb = failure._Traceback([['method', 'filename.py', 123, {}, {}]])
     # Note that we don't need to test that extract_tb correctly extracts
     # the line's contents. In this case, since filename.py doesn't exist,
     # it will just use None.
     self.assertEqual(traceback.extract_tb(tb),
                      [('filename.py', 123, 'method', None)])
예제 #6
0
    def test_manyFrames(self):
        """
        A C{_Traceback} object constructed with multiple frames should be able
        to be passed to L{traceback.extract_tb}, and we should get a list
        containing a tuple for each frame.
        """
        tb = failure._Traceback([
            ['caller1', 'filename.py', 7, {}, {}],
            ['caller2', 'filename.py', 8, {}, {}],
        ], [
            ['method1', 'filename.py', 123, {}, {}],
            ['method2', 'filename.py', 235, {}, {}],
        ])
        self.assertEqual(traceback.extract_tb(tb),
                         [_tb('filename.py', 123, 'method1', None),
                          _tb('filename.py', 235, 'method2', None)])

        # We should also be able to extract_stack on it
        self.assertEqual(traceback.extract_stack(tb.tb_frame),
                         [_tb('filename.py', 7, 'caller1', None),
                          _tb('filename.py', 8, 'caller2', None),
                          _tb('filename.py', 123, 'method1', None),
                          ])