def test_fakeFrameAttributes(self): """ L{_Frame} instances have the C{f_globals} and C{f_locals} attributes bound to C{dict} instance. They also have the C{f_code} attribute bound to something like a code object. """ frame = failure._Frame("dummyname", "dummyfilename") self.assertIsInstance(frame.f_globals, dict) self.assertIsInstance(frame.f_locals, dict) self.assertIsInstance(frame.f_code, failure._Code)
def test_fakeTracebackFrame(self): """ See L{FakeAttributesTests} for more details about this test. """ frame = failure._Frame( ("dummyname", "dummyfilename", 42, {}, {}), None, ) traceback_frame = failure._TracebackFrame(frame) self.assertEqual(traceback_frame.tb_frame, frame) self.assertEqual(traceback_frame.tb_lineno, 42) self.assertIsInstance(traceback_frame.tb_lasti, int) self.assertTrue(hasattr(traceback_frame, "tb_next"))
def test_fakeFrameAttributes(self): """ L{_Frame} instances have the C{f_globals} and C{f_locals} attributes bound to C{dict} instance. They also have the C{f_code} attribute bound to something like a code object. """ back_frame = failure._Frame( ( "dummyparent", "dummyparentfile", 111, None, None, ), None, ) fake_locals = {"local_var": 42} fake_globals = {"global_var": 100} frame = failure._Frame( ( "dummyname", "dummyfilename", 42, fake_locals, fake_globals, ), back_frame, ) self.assertEqual(frame.f_globals, fake_globals) self.assertEqual(frame.f_locals, fake_locals) self.assertIsInstance(frame.f_code, failure._Code) self.assertEqual(frame.f_back, back_frame) self.assertIsInstance(frame.f_builtins, dict) self.assertIsInstance(frame.f_lasti, int) self.assertEqual(frame.f_lineno, 42) self.assertIsInstance(frame.f_trace, type(None))