Jason R. Coombs <[email protected]> added the comment:
> I thought it might be useful for testing purposes if os.path (i.e. ntpath and
> posixpath) had a way to set the home directory that it uses in way that
> wouldn't affect other libraries and child processes.
I was thinking about this, and I'd argue that in the general case, you _want_
to be able to set the home directory in a way that affects child processes. If
you care enough to try to isolate the behavior from the user-local state, you
probably want other libraries and child processes to honor that isolation.
This argument extends to there being a (preferably one) way override a home
directory that's honored by tools and processes of all flavors (e.g. overriding
USERPROFILE has no effect on git commands in a subprocess).
I agree it may prove useful not to affect the global and subprocess state if
possible, but I'd argue in that case, you could probably just patch the library
under test directly.
These processes patching $HOME really are attempting to suppress the user's
local state (or simulate a specific state).
> Not for me in PowerShell 5 and 7:
Weird. You're right, I get the same thing for test-path. And indeed it's not
set in the Python process.
PS C:\WINDOWS\system32> test-path env:home
False
PS C:\WINDOWS\system32> python -c "import os; print(os.environ.get('HOME'))"
None
But strangely, $HOME seems to have some effect.
PS C:\WINDOWS\system32> echo $HOME
C:\Users\jaraco
PS C:\WINDOWS\system32> cd $HOME
PS C:\Users\jaraco>
Do you know what that's about?
I found a couple [Powershell users that seem to think setting $HOME is
something you would want to
do](https://stackoverflow.com/questions/32109375/in-powershell-how-do-i-set-home-variable-before-running-a-script).
And [this Powershell
documentation](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7#environment-variables-that-store-preferences)
makes reference to $HOME.
I see. Powershell defines $HOME as an [Automatic
Variable](https://ss64.com/ps/syntax-automatic-variables.html) internally but
doesn't expose it as an environment variable.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue36264>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com