-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add a set_filter()
context manager to the caplog fixture
#11610
Comments
👍 from me. Bikesheding: with caplog.with_filter(SchnufteCustomFilter()): ...
with caplog.filtering(SchnufteCustomFilter()): ... I prefer the latter, reads naturally to me (although I'm not a native speaker). |
@nicoddemus shall I go ahead and create a PR? |
Yes please |
@nicoddemus what’s the recommendation regarding testing: the |
New functions are preferred. 👍 |
What's the problem this feature will solve?
I need to test a custom filter for logging, and currently I use one of the following two approaches:
or
Describe the solution you'd like
Similar to the
at_level()
context manager I think it would be useful to wrap the second of the above filter setups into a custom context manager, that I can then call like so:Alternative Solutions
See above’s examples, I guess.
Additional context
I’m happy to give a PR a shot: I suppose the change would be adding a method to the LogCaptureFixture, for example:
The text was updated successfully, but these errors were encountered: