Skip to content

Commit

Permalink
hypothesis fix
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Mar 15, 2024
1 parent 1dcbb0c commit a689164
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/functional/grammar/test_grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ def utf8_encodable(terminal: str) -> bool:
return False


ALLOWED_CHARS = st.characters(codec="utf-8", min_codepoint=1)


# With help from hyposmith
# https://github.com/Zac-HD/hypothesmith/blob/master/src/hypothesmith/syntactic.py
class GrammarStrategy(LarkStrategy):
def __init__(self, grammar, start, explicit_strategies):
super().__init__(grammar, start, explicit_strategies)
super().__init__(grammar, start, explicit_strategies, alphabet=ALLOWED_CHARS)
self.terminal_strategies = {
k: v.map(lambda s: s.replace("\0", "")).filter(utf8_encodable)
for k, v in self.terminal_strategies.items() # type: ignore
Expand Down

0 comments on commit a689164

Please sign in to comment.