Skip to content

Commit

Permalink
Test that BDD prefixes are sorted by length
Browse files Browse the repository at this point in the history
  • Loading branch information
pekkaklarck committed Mar 7, 2025
1 parent d57fee9 commit 4fb3f0f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions utest/api/test_languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ class X(Language):
assert_equal(X().bdd_prefixes, {'List', 'is', 'default',
'but', 'any', 'iterable', 'works'})

def test_bdd_prefixes_are_sorted_by_length(self):
class X(Language):
given_prefixes = ['1', 'longest']
when_prefixes = ['XX']
pattern = Languages([X()]).bdd_prefix_regexp.pattern
expected = r'\(longest\|given\|.*\|xx\|1\)\\s'
if not re.fullmatch(expected, pattern):
raise AssertionError(f"Pattern '{pattern}' did not match '{expected}'.")


class TestLanguageFromName(unittest.TestCase):

Expand Down

0 comments on commit 4fb3f0f

Please sign in to comment.