Ejemplo n.º 1
1
def trace_module(import_line):
    root_pt = tracer.init_stack()
    root_pt.import_line = "exec(%s)" % import_line
    with tracer.patch_import():
        with root_pt:
            exec(import_line)
    return root_pt
Ejemplo n.º 2
0
    def test__traceit_from_import(self):
        tr_pt = tracer.init_stack()
        with tracer.patch_import():
            exec("from os import sys")

        self.assertEqual(1, len(tr_pt.children))
        self.assertEqual("from os import sys", tr_pt.children[0].import_line)
Ejemplo n.º 3
0
    def test__traceit_from_import(self):
        tr_pt = tracer.init_stack()
        with tracer.patch_import():
            exec("from os import sys")

        self.assertEqual(1, len(tr_pt.children))
        self.assertEqual("from os import sys", tr_pt.children[0].import_line)
Ejemplo n.º 4
0
def trace_module(import_line):
    root_pt = tracer.init_stack()
    root_pt.import_line = "exec(%s)" % import_line
    with tracer.patch_import():
        with root_pt:
            exec(import_line)
    return root_pt
Ejemplo n.º 5
0
    def test__traceit(self):
        tr_pt = tracer.init_stack()
        with tracer.patch_import():
            exec("import re")

        self.assertEqual(1, len(tr_pt.children))
        self.assertEqual("import re", tr_pt.children[0].import_line)
        self.assertIsNotNone(tr_pt.children[0].filepath)
Ejemplo n.º 6
0
    def test__traceit(self):
        tr_pt = tracer.init_stack()
        with tracer.patch_import():
            exec("import re")

        self.assertEqual(1, len(tr_pt.children))
        self.assertEqual("import re", tr_pt.children[0].import_line)
        self.assertIsNotNone(tr_pt.children[0].filepath)
Ejemplo n.º 7
0
 def test_init_stack(self, mock_trace_pt):
     trace_pt = tracer.init_stack()
     mock_trace_pt.assert_called_once_with("root", 0)
     self.assertEqual(mock_trace_pt.return_value, trace_pt)
     self.assertEqual([mock_trace_pt.return_value], tracer.TRACE_STACK)
Ejemplo n.º 8
0
 def test_init_stack(self, mock_trace_pt):
     trace_pt = tracer.init_stack()
     mock_trace_pt.assert_called_once_with("root", 0)
     self.assertEqual(mock_trace_pt.return_value, trace_pt)
     self.assertEqual([mock_trace_pt.return_value], tracer.TRACE_STACK)