How to use the hunter.VarsSnooper function in hunter

To help you get started, we’ve selected a few hunter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ionelmc / python-hunter / tests / test_cookbook.py View on Github external
def test_examples():
    print("""
    CodePrinter
    """)
    with hunter.trace(stdlib=False, actions=[CodePrinter, VarsSnooper]):
        os.path.join(*map(str, range(10)))

    print("""
    CallPrinter
    """)
    with hunter.trace(stdlib=False, actions=[CallPrinter, VarsSnooper]):
        os.path.join(*map(str, range(10)))
github ionelmc / python-hunter / tests / test_hunter.py View on Github external
def test_varssnooper(LineMatcher):
    lines = StringIO()
    snooper = VarsSnooper(stream=lines)

    @hunter.wrap(actions=[snooper, CodePrinter(stream=lines)])
    def a():
        foo = bar = b = 1
        b = 2
        foo = 3
        foo = bar = 4
        return b

    a()

    print(lines.getvalue())
    lm = LineMatcher(lines.getvalue().splitlines())
    lm.fnmatch_lines([
        "*test_hunter.py*  line              foo = bar = b = 1",
        "*test_hunter.py*  line      [[]b := 1[]]",