Add new test to unsafe matches

This commit is contained in:
shortcutme 2017-07-18 20:55:04 +02:00
parent bb27e3124f
commit bf672bdec3
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -11,7 +11,7 @@ class TestSafeRe:
) )
assert SafeRe.match(".+/data.json", "data/users/1J3rJ8ecnwH2EPYa6MrgZttBNc61ACFiCj/data.json") assert SafeRe.match(".+/data.json", "data/users/1J3rJ8ecnwH2EPYa6MrgZttBNc61ACFiCj/data.json")
@pytest.mark.parametrize("pattern", ["([a-zA-Z]+)*", "(a|aa)+*", "(a|a?)+", "(.*a){10}"]) @pytest.mark.parametrize("pattern", ["([a-zA-Z]+)*", "(a|aa)+*", "(a|a?)+", "(.*a){10}", "((?!json).)*$", "(\w+\d+)+C"])
def testUnsafeMatch(self, pattern): def testUnsafeMatch(self, pattern):
with pytest.raises(SafeRe.UnsafePatternError) as err: with pytest.raises(SafeRe.UnsafePatternError) as err:
SafeRe.match(pattern, "aaaaaaaaaaaaaaaaaaaaaaaa!") SafeRe.match(pattern, "aaaaaaaaaaaaaaaaaaaaaaaa!")