koobs added the comment:

After some sleuthing with Ezio (thank you for the help) and some amateur 
debugging, all conditions in expanduser return the the home directory after 
stripping trailing slashes.

The assertion in Lib/test/test_posixpath.py:264 compares expanduser(path) with 
a path obtained directly from pwd.getpwuidpw_dir "without" submitting it to the 
same treatment,  and thus the test fails when $HOME ends in a "/".

The assertion was added in f11da6cecffd (2011-03-17) in order to show that 
expanduser() "does" infact derive a path from pw_dir, when $HOME is undefined, 
as the test indicates by deleting the environment variable

In so far as using exact path equivalence to make that assertion, the 'home' 
variable in the test either ought to be subjected to the same treatment as 
paths derived via expanduser(), or the assertion relaxed to use assertIsNotNone.

Given the comment in the test: "# expanduser should fall back to using the 
password database", my feeling is that the failure case is that no path is 
returned if a username is not provided in the path passed to expanduser, and as 
such assertIsNotNone is the more specific assertion, but I'll leave it in the 
hands of the experts to make the call.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue17809>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to