classification
Title: FAIL: test_expanduser when $HOME=/
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: SilentGhost, felixonmars, pitrou, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2015-08-28 03:28 by felixonmars, last changed 2016-05-03 19:08 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
issue24950.diff SilentGhost, 2016-02-07 12:34 review
Messages (8)
msg249273 - (view) Author: Felix Yan (felixonmars) * Date: 2015-08-28 03:28
test_expanduser in test.test_posixpath.PosixPathTest fails when the users $HOME being exactly "/", after the patch in issue17809 was introduced.

test test_posixpath failed -- Traceback (most recent call last):
  File "/build/python/src/Python-3.5.0rc2/Lib/test/test_posixpath.py", line 249, in test_expanduser
    self.assertEqual(posixpath.expanduser("~"), home.rstrip("/"))
AssertionError: '/' != ''
- /
+

Would it be appropriate to apply the rstrip() also to the left part of the equation?
msg249274 - (view) Author: Felix Yan (felixonmars) * Date: 2015-08-28 03:37
btw, there seems to be a relevant failure in test_pathlib as well:

test test_pathlib failed -- Traceback (most recent call last):
  File "/build/python/src/Python-3.5.0rc2/Lib/test/test_pathlib.py", line 2015, in test_expanduser
    self.assertEqual(p1.expanduser(), P(userhome) / 'Documents')
AssertionError: PosixPath('/Documents') != PosixPath('Documents')

(not sure if they are really relevant, though)
msg258245 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2016-01-14 22:49
For posixpath the fix is straightforward: just skip that assert if the home ends up being '/' (the '/' is tested above).

For pathlib, I'm not entirely sure what the fix should be.
msg259786 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2016-02-07 12:34
Here is the patch that addresses the issue in both tests. Felix, could you test it?
msg259787 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-02-07 13:06
What if HOME is "//"?
msg259788 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2016-02-07 13:18
> What if HOME is "//"?

Is this possible? What would be the result of these tests? Would they fail? As far as I understand my patch is just fixing problem introduced by fixes from issue 17809.
msg264751 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-03 18:10
Yet one corner case is empty HOME value.
msg264752 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-05-03 18:19
New changeset 194b356c84f5 by Serhiy Storchaka in branch '3.5':
Issue #24950: Fixed expanduser tests when the users home directory in pwd is "/".
https://hg.python.org/cpython/rev/194b356c84f5

New changeset b9b99cb85a5f by Serhiy Storchaka in branch 'default':
Issue #24950: Fixed expanduser tests when the users home directory in pwd is "/".
https://hg.python.org/cpython/rev/b9b99cb85a5f
History
Date User Action Args
2016-05-03 19:08:54serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2016-05-03 18:19:06python-devsetnosy: + python-dev
messages: + msg264752
2016-05-03 18:10:46serhiy.storchakasetmessages: + msg264751
2016-05-03 15:26:28serhiy.storchakasetassignee: serhiy.storchaka
2016-05-03 15:26:15serhiy.storchakalinkissue26933 superseder
2016-02-07 13:18:39SilentGhostsetmessages: + msg259788
2016-02-07 13:06:43serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg259787
2016-02-07 12:34:21SilentGhostsetfiles: + issue24950.diff
keywords: + patch
messages: + msg259786

stage: patch review
2016-01-14 22:49:31SilentGhostsetnosy: + SilentGhost, pitrou

messages: + msg258245
versions: + Python 3.6, - Python 3.3, Python 3.4
2015-08-28 03:37:27felixonmarssetmessages: + msg249274
2015-08-28 03:30:50felixonmarssettitle: FAIL: test_posixpath when $HOME=/ -> FAIL: test_expanduser when $HOME=/
2015-08-28 03:30:27felixonmarssettitle: FAIL: test_expanduser when $HOME=/ -> FAIL: test_posixpath when $HOME=/
2015-08-28 03:28:26felixonmarscreate