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

Fix wrong log_file docs #9878

Merged

Conversation

Zac-HD
Copy link
Member

@Zac-HD Zac-HD commented Apr 21, 2022

If a relative path is passed for the --log-file CLI argument, or the log_file config option is set, it is always resolved relative to the current working directory - pytest doesn't have any special logic beyond that in the standard library logging.FileHandler.

Unfortunately this was incorrectly documented as being relative to the pytest.ini file (not rootdir), which kicked off a considerable chain of confusion. This PR therefore fixes #7336, closes #7350, and closes #9700.

Any proposal to change the current internally-consistent behaviour should start from a fresh issue, and include a description of why the alternative semantics are more desirable, and how to manage the backwards-compatibility implications of moving so many users' log files.

@Zac-HD Zac-HD added type: docs documentation improvement, missing or needing clarification plugin: logging related to the logging builtin plugin labels Apr 21, 2022
@Zac-HD Zac-HD requested a review from nicoddemus April 21, 2022 22:41
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Zac-HD!

We should also update the description of log_file in reference.rst, it is incorrect in there as well.

doc/en/how-to/logging.rst Outdated Show resolved Hide resolved
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
@Zac-HD
Copy link
Member Author

Zac-HD commented Apr 22, 2022

We should also update the description of log_file in reference.rst, it is incorrect in there as well.

This PR does update reference.rst? If you mean the CLI help in logging.py, I thought that it was unnecessary because "relative to cwd" is the obvious interpretation for a CLI path argument, and the existing text doesn't mention anything else. It's also described in the reference as identical to the log_file config, and that is explicitly relative to cwd.

@nicoddemus
Copy link
Member

Oh I could sworn it was updating only logging.rst, sorry my bad!

@nicoddemus nicoddemus added the needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch label Apr 22, 2022
@nicoddemus nicoddemus merged commit 0347957 into pytest-dev:main Apr 22, 2022
@Zac-HD Zac-HD deleted the document-logfile-is-relative-to-cwd branch April 22, 2022 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch plugin: logging related to the logging builtin plugin type: docs documentation improvement, missing or needing clarification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inaccurate documentation
2 participants