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

caplog: Handle disabled logging in 'set_level' and 'at_level' #8711 #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alexlambson
Copy link
Owner

@alexlambson alexlambson commented May 28, 2021

Forces requested caplog logging levels to be enabled if they were disabled via logging.disable()

[attr-defined] mypy error ignored in logging.py because there were existing errors with the imports
and loggin.Logger.manager is an attr set at runtime. Since it's in the standard lib I can't really fix that.

Ignored an attr-defined error in src/_pytest/config/__init__.py because the re-export is necessary.

Closes pytest-dev#8711

@alexlambson alexlambson added the enhancement New feature or request label May 28, 2021
@alexlambson alexlambson self-assigned this May 28, 2021
@alexlambson alexlambson changed the title Handle disabled logging in 'caplog.set_level' and 'caplog.at_level' #… caplog: Handle disabled logging in 'set_level' and 'at_level' #8711 May 28, 2021
@alexlambson alexlambson force-pushed the issue-8711-handle-disabled-logging branch 2 times, most recently from 377d826 to e52ee7c Compare November 11, 2021 05:49
Alex Lambson and others added 4 commits May 17, 2023 21:25
…ytest-dev#8711

Forces requested `caplog` logging levels to be enabled if they were disabled via `logging.disable()`

`[attr-defined]` mypy error ignored in `logging.py` because there were existing errors with the imports
and `loggin.Logger.manager` is an attr set at runtime. Since it's in the standard lib I can't really fix that.

Ignored an attr-defined error in `src/_pytest/config/__init__.py` because the re-export is necessary.

Issue: pytest-dev#8711
- Resolves issues from review provided by https://github.com/andrewdotn

- Fixed spelling errors

- Improved logic in `force_enable_logging`

- Make a fixture to un-disable logging after a test so that logging will be un-disabled even if the test fails due to an assertion error.
The fixture is in `test_fixture.py` because we can't `import logging` in `conftest.py` because there is a module called `logging` in the same folder.

- Mypy implicit import error. I can't commit without this.

Issue: pytest-dev#8711
PR: pytest-dev#8758
- Adds test coverage for `force_enable_logging` with a string `level`. Fixes [code coverage check](https://github.com/pytest-dev/pytest/pull/8758/checks?check_run_id=4123920877)

Issue: pytest-dev#8711
PR: pytest-dev#8758
- Address review ad rebase to latest from main
- Make `force_enable_logging` private.

Issue: pytest-dev#8711
PR: pytest-dev#8758
@alexlambson alexlambson force-pushed the issue-8711-handle-disabled-logging branch from e52ee7c to 7f89996 Compare May 18, 2023 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
1 participant