예제 #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
예제 #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)
예제 #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)
예제 #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
예제 #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)
예제 #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__)
예제 #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)
예제 #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__)