Exemplo 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
Exemplo 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)
Exemplo 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)
Exemplo 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
Exemplo 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)
Exemplo n.º 6
0
    def test_patch_import(self, mock_traceit):
        normal_import = builtins.__import__

        with tracer.patch_import():
            self.assertEqual(mock_traceit.return_value, builtins.__import__)
            self.assertNotEqual(normal_import, builtins.__import__)

        self.assertEqual(normal_import, builtins.__import__)
Exemplo n.º 7
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)
Exemplo n.º 8
0
    def test_patch_import(self, mock_traceit):
        normal_import = builtins.__import__

        with tracer.patch_import():
            self.assertEqual(mock_traceit.return_value, builtins.__import__)
            self.assertNotEqual(normal_import, builtins.__import__)

        self.assertEqual(normal_import, builtins.__import__)