Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regex strategy ignoring re.VERBOSE #992

Closed
AlvarBer opened this issue Nov 27, 2017 · 1 comment
Closed

regex strategy ignoring re.VERBOSE #992

AlvarBer opened this issue Nov 27, 2017 · 1 comment
Assignees
Labels
bug something is clearly wrong here

Comments

@AlvarBer
Copy link

I have a regex expression that uses re.VERBOSE flag for improved readability, and when it is used as a strategy it throws a FailedHealthCheck, however the same regex without the flag and compressed on a single line works fine.

I suspect this is due to from_regex strategy ignoring the re.VERBOSE flag and trying to match the full regex including whitespace and newlines, a quick search in searchstrategy/regex.py shows that the VERBOSE flag is not checked anywhere.

@Zac-HD Zac-HD added the bug something is clearly wrong here label Nov 28, 2017
@Zac-HD Zac-HD self-assigned this Nov 28, 2017
@Zac-HD
Copy link
Member

Zac-HD commented Nov 28, 2017

Thanks for the report - your diagnosis is correct, this is definitely a bug, and we should fix it. Notes on that:

  • parse things with sre_parse.parse(regex.pattern, flags=regex.flags)
  • _strategy should take a boolean is_text, not the pattern itself
  • add some tests with re.VERBOSE, including patterns where this changes the match
  • check whether there are other neglected flags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something is clearly wrong here
Projects
None yet
Development

No branches or pull requests

2 participants