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_anchor(path, anchor, expected):
'''Parse path with specific anchor setting.'''
pattern = '/static/{variable}'
template = Template('test', pattern, anchor=anchor)
if not expected:
with pytest.raises(ParseError):
template.parse(path)
else:
data = template.parse(path)
assert data == {'variable': 'value'}
def test_non_matching_parse(pattern, path):
'''Extract data from non-matching path.'''
template = Template('test', pattern)
with pytest.raises(ParseError):
data = template.parse(path)