Only call _setup_cli_logging in __init__#4720
Only call _setup_cli_logging in __init__#4720RonnyPfannschmidt merged 1 commit intopytest-dev:masterfrom
Conversation
|
@RonnyPfannschmidt if you agree, let's close this in favor of #4719 |
|
It seems as if it is not so easy. Passing trylast=True to the hookimpl decorator used for pytest_configure leads to a couple of test failures. |
RonnyPfannschmidt
left a comment
There was a problem hiding this comment.
looks good to me and i agree to the superseeding
The tests are failing because the handling of the verbosity level has changed. without --verbose on the cmd line a simple test outputs: but with --verbose (= same output as without --verbose before my change) it outputs Any ideas? |
I know what the problem is. Before this PR config.option.verbose=1 was called in pytest_configure of the logging plugin before the terminalreporter plugin was configured. Now it is the other way around. I guess that the terminalreporter doesn't notice with the code from this PR that the logging plugin manually sets the verbose flag to 1. Any ideas @nicoddemus ? |
|
@Thisch i did a quick check of the terminal plugin, and im under the impression its inconsistent in handling verbosity (parts use config.option.verbose, parts use a stored copy) a quick workaround would be to fetch the terminalwriter instance as well setting its |
|
|
||
| self.log_cli_handler = None | ||
|
|
||
| terminal_reporter = self._config.pluginmanager.get_plugin("terminalreporter") |
There was a problem hiding this comment.
Should this code kept being wrapped in a function/method (_setup_cli_logging)?
There was a problem hiding this comment.
I also prefer keeping the _setup_cli_method. Thx for pointing that out!
2bb2593 to
ac17af8
Compare
Codecov Report
@@ Coverage Diff @@
## master #4720 +/- ##
==========================================
- Coverage 95.68% 95.67% -0.02%
==========================================
Files 113 113
Lines 24963 24965 +2
Branches 2478 2478
==========================================
- Hits 23886 23885 -1
Misses 762 762
- Partials 315 318 +3
Continue to review full report at Codecov.
|
src/_pytest/logging.py
Outdated
| terminal_reporter = self._config.pluginmanager.get_plugin("terminalreporter") | ||
| # FIXME don't set verbosity level and derived attributes of | ||
| # terminalwriter directly | ||
| terminal_reporter.verbosity = self._config.option.verbose |
There was a problem hiding this comment.
What if we change verbosity, showheader, etc, to read-only properties? As we have seen, setting them manually is error prone and leads to surprising results.
There was a problem hiding this comment.
thats a long term goal, a initial gloss over review of terminalwriter indicated, that it is inconsistent in terms of option/configuration usage
There was a problem hiding this comment.
Why you mean a long term goal @RonnyPfannschmidt ? Changing them to read-only properties should be really simple and would avoid the hack that @Thisch had to put in place. 😁
There was a problem hiding this comment.
Note that this hack does not fully solve all issues with the unit tests. I can't really explain why the terminalwrapper plugin seems to be not ready when LogginPlugin.init is called in the travis-ci jobs (Nonetype has not attribute ...; see https://travis-ci.org/pytest-dev/pytest/jobs/489189341)
Any ideas?
There was a problem hiding this comment.
Oh xdist disables the terminal writer, so it never gets loaded.
There was a problem hiding this comment.
@nicoddemus since there seems tobe inconsistent usage, that issue should be resolved in a own pr instead of shoehorning it into this one which is different
There was a problem hiding this comment.
Problem is that the tests are breaking because of this inconsistency... I'm not against making the change here (in separate commits of course), but if you guys prefer then we should open a new PR changing the terminal attributes to read-only properties, and when that gets merged this PR should be rebased on that one. @Thisch you up for it?
ac17af8 to
0ce8b91
Compare
|
Can this be merged now? |
|
@Thisch thanks for the reminder |
Supersedes #4719
Thanks for submitting a PR, your contribution is really appreciated!
Here's a quick checklist that should be present in PRs (you can delete this text from the final description, this is
just a guideline):
changelogfolder, with a name like<ISSUE NUMBER>.<TYPE>.rst. See changelog/README.rst for details.masterbranch for bug fixes, documentation updates and trivial changes.featuresbranch for new features and removals/deprecations.Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
AUTHORSin alphabetical order;