Example #1
0
def location_of_functions_is_stored():
    program_source = """
def repeat(x, y):
    return x * y

print(repeat("hello ", 3))
"""
    with program_with_module(program_source) as program:
        trace = farthing.trace(trace_paths=[program.directory_path], argv=[program.run_path])
        assert_that(trace, m.contains(m.has_properties({
            "location": m.has_properties({
                "path": program.module_path,
                "lineno": 2,
                "col_offset": 0
            }),
        })))
Example #2
0
def _run_and_trace(program_source):
    with program_with_module(program_source) as program:
        return farthing.trace(trace_paths=[program.directory_path], argv=[program.run_path])
Example #3
0
def sys_argv_is_unchanged_by_running_trace():
    with program_with_module("") as program:
        original_argv = sys.argv[:]
        farthing.trace(argv=[program.run_path], trace_paths=[program.directory_path])
        assert_equal(original_argv, sys.argv)