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: move 'import getpass' statement to try-clause #9871
Conversation
Please squash-and-merge. |
for more information, see https://pre-commit.ci
Hi Paul - thanks so much for reporting and fixing this bizarre bug! I also have no idea why import getpass
can fail, but since it clearly can in some cases this looks like the correct fix to me.
One small comment below about the changelog entry, and then I'll be happy to merge this
changelog/9871.bugfix.rst
Outdated
@@ -0,0 +1 @@ | |||
Handle ``ImportError`` for ``getpass`` import in ``_pytest.tempdir.get_user`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the changelog is part of our user-facing documentation, we should describe this in terms of user-visible symptoms which are visible from the public API. In this case, I think that means something like:
Fix a bizarre (and fortunately rare) bug where the `temp_path` fixture could raise
an internal error while attempting to get the current user's username.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, done!
This fixes an issue that I have in combination with coverage and the
tmp_path
fixture:I am not sure what exactly causes this. Maybe coverage hides some environment variables. I also find it strange that It is not possible to import a module from the standard library. But in any case, I think this fix is light-weight and should not cause any trouble in the future.
The error message goes like this: