-
Notifications
You must be signed in to change notification settings - Fork 53
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
DRY and simple way to capture logging #285
Labels
bug
Something isn't working
Comments
Thanks for the report! I naively assumed that logging would be captured in the same was as printing to stdout. For this, we may need to look at how pytest or other frameworks handle it as I don't have any ideas from the top of my head. I quite like the idea of adding |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
First of all: congrats for the work on ward!
I'm failing to find a DRY and simple way to configure logging so ward would capture it.
Here is a very basic sample:
Running ward will output something like this:
For what I understand, this is because logging is configured before ward try to capture it. And this seems to be because of the way
redirect_stdout/stderr
works (see this bug report for a bit of context).In other word, AFAIK, the logging should be configured after
redirect_stderr
has been called.This would be a working sample of this scenario:
But that would mean adding the fixture
configure_logging
to each and every test, which is not ideal for obvious reasons.Any better suggestion ?
I'm thinking about some per-test hook or some fixture
autoloading
mode (but I do appreciate the path taken by ward to try to avoid magic; while in this given case, pytest has a (magical?) way to work around this race condition).As a user, I'm expecting to be able to configure a logging with a DEBUG level and to have this output displayed on the console only in case of a failing test.
Thanks for your lights! :)
PS: talking about hooks, what about automatically adding the value of
--path
as a plugin module candidate ? That way one may implement hooks insidetest/__init__.py
without the need to either add apyproject.toml
or pass--hook-module
to the command line call.The text was updated successfully, but these errors were encountered: