Skip to content

Commit

Permalink
fix: Respect pytest log_cli ini option
Browse files Browse the repository at this point in the history
  • Loading branch information
adigitoleo committed Aug 12, 2024
1 parent 75c23fd commit 3707ea9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ testpaths = ["tests"]
# --show-capture=no : Don't show captured output for failed tests, use -v instead.
# -p no:logging : Disable built-in logging plugin, we have our own.
addopts = "--tb=short --capture=fd --show-capture=no -p no:logging"
# NOTE: We do not respect the log_cli=true option. Use pytest -v to get live logs instead.

# Global linter and devtools settings.
[tool.ruff]
Expand Down
7 changes: 4 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def pytest_configure(config):

# Hook up our logging plugin last,
# it relies on terminalreporter and capturemanager.
# Because the log_cli=true init option is not introspectable, we use -v instead.
# To subclass the logging plugin we also had to break --capture except for -s
# (--capture=no), so bail if the user tries to set --capture=method.
if config.option.log_cli_level is not None:
Expand Down Expand Up @@ -132,7 +131,7 @@ def pytest_configure(config):
+ "use --capture=fd"
),
) from None
if config.option.verbose > 0:
if config.option.verbose > 0 or config.getini("log_cli"):
config.pluginmanager.register(PyDRexLiveLogger(config), PyDRexLiveLogger.name)


Expand All @@ -157,6 +156,8 @@ def pytest_collection_modifyitems(config, items):

@pytest.fixture(scope="session")
def verbose(request):
if request.config.option.verbose == 0 and request.config.getini("log_cli"):
return 1
return request.config.option.verbose


Expand Down Expand Up @@ -195,7 +196,7 @@ def console_handler(request):
Otherwise, returns the default pydrex CLI logging handler.
"""
if request.config.option.verbose > 0:
if request.config.option.verbose > 0 or request.config.getini("log_cli"):
return request.config.pluginmanager.get_plugin(
"pydrex-live-logger"
).log_cli_handler
Expand Down

0 comments on commit 3707ea9

Please sign in to comment.