Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0e120525
Commit
0e120525
authored
May 03, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Issue #24950: Fixed expanduser tests when the users home directory in pwd is "/".
Based on patch by SilentGhost.
parents
478be14e
a3fd0b26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
Lib/test/test_pathlib.py
Lib/test/test_pathlib.py
+1
-1
Lib/test/test_posixpath.py
Lib/test/test_posixpath.py
+9
-4
No files found.
Lib/test/test_pathlib.py
View file @
0e120525
...
...
@@ -2062,7 +2062,7 @@ class PosixPathTest(_BasePathTest, unittest.TestCase):
import
pwd
pwdent
=
pwd
.
getpwuid
(
os
.
getuid
())
username
=
pwdent
.
pw_name
userhome
=
pwdent
.
pw_dir
.
rstrip
(
'/'
)
userhome
=
pwdent
.
pw_dir
.
rstrip
(
'/'
)
or
'/'
# find arbitrary different user (if exists)
for
pwdent
in
pwd
.
getpwall
():
othername
=
pwdent
.
pw_name
...
...
Lib/test/test_posixpath.py
View file @
0e120525
...
...
@@ -214,6 +214,13 @@ class PosixPathTest(unittest.TestCase):
def
test_expanduser
(
self
):
self
.
assertEqual
(
posixpath
.
expanduser
(
"foo"
),
"foo"
)
self
.
assertEqual
(
posixpath
.
expanduser
(
b"foo"
),
b"foo"
)
with
support
.
EnvironmentVarGuard
()
as
env
:
for
home
in
'/'
,
''
,
'//'
,
'///'
:
with
self
.
subTest
(
home
=
home
):
env
[
'HOME'
]
=
home
self
.
assertEqual
(
posixpath
.
expanduser
(
"~"
),
"/"
)
self
.
assertEqual
(
posixpath
.
expanduser
(
"~/"
),
"/"
)
self
.
assertEqual
(
posixpath
.
expanduser
(
"~/foo"
),
"/foo"
)
try
:
import
pwd
except
ImportError
:
...
...
@@ -237,14 +244,12 @@ class PosixPathTest(unittest.TestCase):
self
.
assertIsInstance
(
posixpath
.
expanduser
(
b"~foo/"
),
bytes
)
with
support
.
EnvironmentVarGuard
()
as
env
:
env
[
'HOME'
]
=
'/'
self
.
assertEqual
(
posixpath
.
expanduser
(
"~"
),
"/"
)
self
.
assertEqual
(
posixpath
.
expanduser
(
"~/foo"
),
"/foo"
)
# expanduser should fall back to using the password database
del
env
[
'HOME'
]
home
=
pwd
.
getpwuid
(
os
.
getuid
()).
pw_dir
# $HOME can end with a trailing /, so strip it (see #17809)
self
.
assertEqual
(
posixpath
.
expanduser
(
"~"
),
home
.
rstrip
(
"/"
))
home
=
home
.
rstrip
(
"/"
)
or
'/'
self
.
assertEqual
(
posixpath
.
expanduser
(
"~"
),
home
)
def
test_normpath
(
self
):
self
.
assertEqual
(
posixpath
.
normpath
(
""
),
"."
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment