Skip to content

Commit

Permalink
Test SafeRe repetition limit
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcutme committed Jul 14, 2017
1 parent ac1a03d commit 6a4882d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Test/TestSafeRe.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ def testSafeMatch(self):
def testUnsafeMatch(self, pattern):
with pytest.raises(SafeRe.UnsafePatternError) as err:
SafeRe.match(pattern, "aaaaaaaaaaaaaaaaaaaaaaaa!")
assert "Potentially unsafe" in str(err)
assert "Potentially unsafe" in str(err)

@pytest.mark.parametrize("pattern", ["^(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)(.*a)$"])
def testUnsafeRepetition(self, pattern):
with pytest.raises(SafeRe.UnsafePatternError) as err:
SafeRe.match(pattern, "aaaaaaaaaaaaaaaaaaaaaaaa!")
assert "More than" in str(err)

0 comments on commit 6a4882d

Please sign in to comment.