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_from_predicate_no_predicate(LineMatcher):
buff = StringIO()
from sample7 import one
with trace(From(Q(function='five')), action=CallPrinter(stream=buff)):
one()
output = buff.getvalue()
lm = LineMatcher(output.splitlines())
lm.fnmatch_lines([
"* call => five()",
"* line for i in range(1): # five",
"* line return i",
"* return <= five: 0",
])
assert 'four' not in output
assert 'three' not in output
assert 'two' not in output
assert 'one' not in output
def test_from_predicate_line(LineMatcher):
buff = StringIO()
from sample7 import one
with trace(From(Q(fullsource_has='in_five'), CallPrinter(stream=buff), watermark=-1)):
one()
output = buff.getvalue()
lm = LineMatcher(output.splitlines())
lm.fnmatch_lines([
"* line * for i in range(1): # five",
"* line * return i",
])
assert 'four' not in output
assert 'three' not in output
assert 'two' not in output
assert 'one' not in output
def test_from_predicate(LineMatcher):
buff = StringIO()
from sample7 import one
with trace(From(Q(function='five'), CallPrinter(stream=buff))):
one()
output = buff.getvalue()
lm = LineMatcher(output.splitlines())
lm.fnmatch_lines([
"* call => five()",
"* line for i in range(1): # five",
"* line return i",
"* return <= five: 0",
])
assert 'four' not in output
assert 'three' not in output
assert 'two' not in output
assert 'one' not in output
def test_from_predicate_line_no_predicate(LineMatcher):
buff = StringIO()
from sample7 import one
with trace(From(Q(fullsource_has='in_five'), watermark=-1), action=CallPrinter(stream=buff)):
one()
output = buff.getvalue()
lm = LineMatcher(output.splitlines())
lm.fnmatch_lines([
"* line * for i in range(1): # five",
"* line * return i",
])
assert 'four' not in output
assert 'three' not in output
assert 'two' not in output
assert 'one' not in output
def test_from_typeerror():
pytest.raises(TypeError, From, 1, 2, kind=3)
From(1, 2, 3)
From(kind=1, function=2)
pytest.raises(TypeError, From, junk=1)
def test_from_typeerror():
pytest.raises(TypeError, From, 1, 2, kind=3)
From(1, 2, 3)
From(kind=1, function=2)
pytest.raises(TypeError, From, junk=1)
def test_from_typeerror():
pytest.raises(TypeError, From, 1, 2, kind=3)
From(1, 2, 3)
From(kind=1, function=2)
pytest.raises(TypeError, From, junk=1)