Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)))
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[]]",