-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Cut down on noise in expected strings #54
Comments
Related #45 |
I'd be happy to work on a PR for this if it would be welcome. |
@brunns it is! Thank you! |
Is there a one-liner for running the tests, or do I create and activate a venv by hand, then run pytest? |
Yes, activate your |
I'm assuming we'd want a flag to activate this behavior. Otherwise,, the change wouldn't be backward compatible. |
@brunns yes 👍 |
So, two options really. There could be have a flag level test, or the comment could be annotated somehow, so we could mix the two styles. Or, I suppose, both? I've made a start on the former approach in #55 (though not actually implemented the functionality yet!) but it would be easy enough to allow both options. |
OK, #55 now implements regex matching of the messages, with a flag at the test level. Can someone let me know if I'm heading in the right direction? If so, I'll look at allowing regexes for specific messages, and also maybe the template idea. |
* Some refactoring before making the change - use an object for expected output rather than a string. * Simple regex case now working * A spot of clean-up. * Document regex option. * Specify default value for regex flag. * Add test for regexes inb out section. * Add test to ensure that regexes ony run if the flag is switched on. * Allow regexes on specific messages. * Fix regex - single line flag froup needed to be optional. * Add simple failing simple cases. * Add case for mismatching regex.
Templates - would we want those at the level of a single test, or a single set of tests across the whole test file? I'm thinking the latter, given that the aim is to enable reuse. |
What templates are you talking about in this context? 🤔 |
From the original issue report. |
Oh, I've missed this part. What kind of common-case templates do you think we need? |
I don't need them myself, but the OP's example included being able to specify a |
It was with this in mind that I did #57, since it would presumably use the same engine. |
#58 contains a sketch of a solution. BTW, I believe that if templates at the individual test level is prefered, you can already do that using |
Are you planning a release, @sobolevn? I'd find this very useful over at https://github.com/hamcrest/PyHamcrest ! |
Yes, I will reelase it this week! Thanks again! |
Done! Thanks a lot @brunns |
Many times the full expectation string is long and includes low value information. I'd like to introduce some way to cut down on that noise. One thought is to make the expected string a fullmatch regex. This could also handle #45.
It might also be possible to make the expected strings templates to enable reuse, and perhaps package some of the common patterns with the tool.
The language here is strings, so using the common tools for that: regexes and templates, makes a lot of sense.
The text was updated successfully, but these errors were encountered: