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
afc624b5
Commit
afc624b5
authored
Mar 08, 2010
by
Florent Xicluna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge other tests from test_*path.py into test_genericpath.CommonTest, and do some cleanup.
parent
733261f7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
130 deletions
+57
-130
Lib/test/test_genericpath.py
Lib/test/test_genericpath.py
+24
-0
Lib/test/test_macpath.py
Lib/test/test_macpath.py
+33
-58
Lib/test/test_posixpath.py
Lib/test/test_posixpath.py
+0
-72
No files found.
Lib/test/test_genericpath.py
View file @
afc624b5
...
...
@@ -47,6 +47,18 @@ class GenericTest(unittest.TestCase):
commonprefix
([
"/home/swen/spam"
,
"/home/swen/spam"
]),
"/home/swen/spam"
)
self
.
assertEqual
(
commonprefix
([
"home:swenson:spam"
,
"home:swen:spam"
]),
"home:swen"
)
self
.
assertEqual
(
commonprefix
([
":home:swen:spam"
,
":home:swen:eggs"
]),
":home:swen:"
)
self
.
assertEqual
(
commonprefix
([
":home:swen:spam"
,
":home:swen:spam"
]),
":home:swen:spam"
)
self
.
assertEqual
(
commonprefix
([
b"/home/swenson/spam"
,
b"/home/swen/spam"
]),
...
...
@@ -60,6 +72,18 @@ class GenericTest(unittest.TestCase):
commonprefix
([
b"/home/swen/spam"
,
b"/home/swen/spam"
]),
b"/home/swen/spam"
)
self
.
assertEqual
(
commonprefix
([
b"home:swenson:spam"
,
b"home:swen:spam"
]),
b"home:swen"
)
self
.
assertEqual
(
commonprefix
([
b":home:swen:spam"
,
b":home:swen:eggs"
]),
b":home:swen:"
)
self
.
assertEqual
(
commonprefix
([
b":home:swen:spam"
,
b":home:swen:spam"
]),
b":home:swen:spam"
)
testlist
=
[
''
,
'abc'
,
'Xbcd'
,
'Xb'
,
'XY'
,
'abcd'
,
'aXc'
,
'abd'
,
'ab'
,
'aX'
,
'abcX'
]
...
...
Lib/test/test_macpath.py
View file @
afc624b5
...
...
@@ -26,23 +26,6 @@ class MacPathTestCase(unittest.TestCase):
self
.
assertFalse
(
isabs
(
b":foo:bar"
))
self
.
assertFalse
(
isabs
(
b":foo:bar:"
))
def
test_commonprefix
(
self
):
commonprefix
=
macpath
.
commonprefix
self
.
assertEqual
(
commonprefix
([
"home:swenson:spam"
,
"home:swen:spam"
]),
"home:swen"
)
self
.
assertEqual
(
commonprefix
([
":home:swen:spam"
,
":home:swen:eggs"
]),
":home:swen:"
)
self
.
assertEqual
(
commonprefix
([
":home:swen:spam"
,
":home:swen:spam"
]),
":home:swen:spam"
)
self
.
assertTrue
(
commonprefix
([
b"home:swenson:spam"
,
b"home:swen:spam"
])
==
b"home:swen"
)
self
.
assertTrue
(
commonprefix
([
b":home:swen:spam"
,
b":home:swen:eggs"
])
==
b":home:swen:"
)
self
.
assertTrue
(
commonprefix
([
b":home:swen:spam"
,
b":home:swen:spam"
])
==
b":home:swen:spam"
)
def
test_split
(
self
):
split
=
macpath
.
split
self
.
assertEqual
(
split
(
"foo:bar"
),
...
...
@@ -54,36 +37,28 @@ class MacPathTestCase(unittest.TestCase):
self
.
assertEqual
(
split
(
":conky:mountpoint:"
),
(
':conky:mountpoint'
,
''
))
self
.
assertEqual
s
(
split
(
b"foo:bar"
),
self
.
assertEqual
(
split
(
b"foo:bar"
),
(
b'foo:'
,
b'bar'
))
self
.
assertEqual
s
(
split
(
b"conky:mountpoint:foo:bar"
),
self
.
assertEqual
(
split
(
b"conky:mountpoint:foo:bar"
),
(
b'conky:mountpoint:foo'
,
b'bar'
))
self
.
assertEqual
s
(
split
(
b":"
),
(
b''
,
b''
))
self
.
assertEqual
s
(
split
(
b":conky:mountpoint:"
),
self
.
assertEqual
(
split
(
b":"
),
(
b''
,
b''
))
self
.
assertEqual
(
split
(
b":conky:mountpoint:"
),
(
b':conky:mountpoint'
,
b''
))
def
test_join
(
self
):
join
=
macpath
.
join
self
.
assertEquals
(
join
(
'a'
,
'b'
),
':a:b'
)
self
.
assertEquals
(
join
(
''
,
'a:b'
),
'a:b'
)
self
.
assertEquals
(
join
(
'a:b'
,
'c'
),
'a:b:c'
)
self
.
assertEquals
(
join
(
'a:b'
,
':c'
),
'a:b:c'
)
self
.
assertEquals
(
join
(
'a'
,
':b'
,
':c'
),
':a:b:c'
)
self
.
assertEquals
(
join
(
b'a'
,
b'b'
),
b':a:b'
)
self
.
assertEquals
(
join
(
b''
,
b'a:b'
),
b'a:b'
)
self
.
assertEquals
(
join
(
b'a:b'
,
b'c'
),
b'a:b:c'
)
self
.
assertEquals
(
join
(
b'a:b'
,
b':c'
),
b'a:b:c'
)
self
.
assertEquals
(
join
(
b'a'
,
b':b'
,
b':c'
),
b':a:b:c'
)
def
test_splitdrive
(
self
):
splitdrive
=
macpath
.
splitdrive
self
.
assertEqual
(
splitdrive
(
"foo:bar"
),
(
''
,
'foo:bar'
))
self
.
assertEqual
(
splitdrive
(
":foo:bar"
),
(
''
,
':foo:bar'
))
self
.
assertEquals
(
splitdrive
(
b"foo:bar"
),
(
b''
,
b'foo:bar'
))
self
.
assertEquals
(
splitdrive
(
b":foo:bar"
),
(
b''
,
b':foo:bar'
))
self
.
assertEqual
(
join
(
'a'
,
'b'
),
':a:b'
)
self
.
assertEqual
(
join
(
''
,
'a:b'
),
'a:b'
)
self
.
assertEqual
(
join
(
'a:b'
,
'c'
),
'a:b:c'
)
self
.
assertEqual
(
join
(
'a:b'
,
':c'
),
'a:b:c'
)
self
.
assertEqual
(
join
(
'a'
,
':b'
,
':c'
),
':a:b:c'
)
self
.
assertEqual
(
join
(
b'a'
,
b'b'
),
b':a:b'
)
self
.
assertEqual
(
join
(
b''
,
b'a:b'
),
b'a:b'
)
self
.
assertEqual
(
join
(
b'a:b'
,
b'c'
),
b'a:b:c'
)
self
.
assertEqual
(
join
(
b'a:b'
,
b':c'
),
b'a:b:c'
)
self
.
assertEqual
(
join
(
b'a'
,
b':b'
,
b':c'
),
b':a:b:c'
)
def
test_splitext
(
self
):
splitext
=
macpath
.
splitext
...
...
@@ -95,27 +70,27 @@ class MacPathTestCase(unittest.TestCase):
self
.
assertEqual
(
splitext
(
""
),
(
''
,
''
))
self
.
assertEqual
(
splitext
(
"foo.bar.ext"
),
(
'foo.bar'
,
'.ext'
))
self
.
assertEqual
s
(
splitext
(
b":foo.ext"
),
(
b':foo'
,
b'.ext'
))
self
.
assertEqual
s
(
splitext
(
b"foo:foo.ext"
),
(
b'foo:foo'
,
b'.ext'
))
self
.
assertEqual
s
(
splitext
(
b".ext"
),
(
b'.ext'
,
b''
))
self
.
assertEqual
s
(
splitext
(
b"foo.ext:foo"
),
(
b'foo.ext:foo'
,
b''
))
self
.
assertEqual
s
(
splitext
(
b":foo.ext:"
),
(
b':foo.ext:'
,
b''
))
self
.
assertEqual
s
(
splitext
(
b""
),
(
b''
,
b''
))
self
.
assertEqual
s
(
splitext
(
b"foo.bar.ext"
),
(
b'foo.bar'
,
b'.ext'
))
self
.
assertEqual
(
splitext
(
b":foo.ext"
),
(
b':foo'
,
b'.ext'
))
self
.
assertEqual
(
splitext
(
b"foo:foo.ext"
),
(
b'foo:foo'
,
b'.ext'
))
self
.
assertEqual
(
splitext
(
b".ext"
),
(
b'.ext'
,
b''
))
self
.
assertEqual
(
splitext
(
b"foo.ext:foo"
),
(
b'foo.ext:foo'
,
b''
))
self
.
assertEqual
(
splitext
(
b":foo.ext:"
),
(
b':foo.ext:'
,
b''
))
self
.
assertEqual
(
splitext
(
b""
),
(
b''
,
b''
))
self
.
assertEqual
(
splitext
(
b"foo.bar.ext"
),
(
b'foo.bar'
,
b'.ext'
))
def
test_ismount
(
self
):
ismount
=
macpath
.
ismount
self
.
assertEqual
s
(
ismount
(
"a:"
),
True
)
self
.
assertEqual
s
(
ismount
(
"a:b"
),
False
)
self
.
assertEqual
s
(
ismount
(
"a:b:"
),
True
)
self
.
assertEqual
s
(
ismount
(
""
),
False
)
self
.
assertEqual
s
(
ismount
(
":"
),
False
)
self
.
assertEqual
s
(
ismount
(
b"a:"
),
True
)
self
.
assertEqual
s
(
ismount
(
b"a:b"
),
False
)
self
.
assertEqual
s
(
ismount
(
b"a:b:"
),
True
)
self
.
assertEqual
s
(
ismount
(
b""
),
False
)
self
.
assertEqual
s
(
ismount
(
b":"
),
False
)
self
.
assertEqual
(
ismount
(
"a:"
),
True
)
self
.
assertEqual
(
ismount
(
"a:b"
),
False
)
self
.
assertEqual
(
ismount
(
"a:b:"
),
True
)
self
.
assertEqual
(
ismount
(
""
),
False
)
self
.
assertEqual
(
ismount
(
":"
),
False
)
self
.
assertEqual
(
ismount
(
b"a:"
),
True
)
self
.
assertEqual
(
ismount
(
b"a:b"
),
False
)
self
.
assertEqual
(
ismount
(
b"a:b:"
),
True
)
self
.
assertEqual
(
ismount
(
b""
),
False
)
self
.
assertEqual
(
ismount
(
b":"
),
False
)
def
test_normpath
(
self
):
normpath
=
macpath
.
normpath
...
...
Lib/test/test_posixpath.py
View file @
afc624b5
...
...
@@ -136,78 +136,6 @@ class PosixPathTest(unittest.TestCase):
self
.
assertEqual
(
posixpath
.
dirname
(
b"////foo"
),
b"////"
)
self
.
assertEqual
(
posixpath
.
dirname
(
b"//foo//bar"
),
b"//foo"
)
def
test_commonprefix
(
self
):
self
.
assertEqual
(
posixpath
.
commonprefix
([]),
""
)
self
.
assertEqual
(
posixpath
.
commonprefix
([
"/home/swenson/spam"
,
"/home/swen/spam"
]),
"/home/swen"
)
self
.
assertEqual
(
posixpath
.
commonprefix
([
"/home/swen/spam"
,
"/home/swen/eggs"
]),
"/home/swen/"
)
self
.
assertEqual
(
posixpath
.
commonprefix
([
"/home/swen/spam"
,
"/home/swen/spam"
]),
"/home/swen/spam"
)
self
.
assertEqual
(
posixpath
.
commonprefix
([
b"/home/swenson/spam"
,
b"/home/swen/spam"
]),
b"/home/swen"
)
self
.
assertEqual
(
posixpath
.
commonprefix
([
b"/home/swen/spam"
,
b"/home/swen/eggs"
]),
b"/home/swen/"
)
self
.
assertEqual
(
posixpath
.
commonprefix
([
b"/home/swen/spam"
,
b"/home/swen/spam"
]),
b"/home/swen/spam"
)
testlist
=
[
''
,
'abc'
,
'Xbcd'
,
'Xb'
,
'XY'
,
'abcd'
,
'aXc'
,
'abd'
,
'ab'
,
'aX'
,
'abcX'
]
for
s1
in
testlist
:
for
s2
in
testlist
:
p
=
posixpath
.
commonprefix
([
s1
,
s2
])
self
.
assertTrue
(
s1
.
startswith
(
p
))
self
.
assertTrue
(
s2
.
startswith
(
p
))
if
s1
!=
s2
:
n
=
len
(
p
)
self
.
assertNotEqual
(
s1
[
n
:
n
+
1
],
s2
[
n
:
n
+
1
])
def
test_getsize
(
self
):
f
=
open
(
support
.
TESTFN
,
"wb"
)
try
:
f
.
write
(
b"foo"
)
f
.
close
()
self
.
assertEqual
(
posixpath
.
getsize
(
support
.
TESTFN
),
3
)
finally
:
if
not
f
.
closed
:
f
.
close
()
def
test_time
(
self
):
f
=
open
(
support
.
TESTFN
,
"wb"
)
try
:
f
.
write
(
b"foo"
)
f
.
close
()
f
=
open
(
support
.
TESTFN
,
"ab"
)
f
.
write
(
b"bar"
)
f
.
close
()
f
=
open
(
support
.
TESTFN
,
"rb"
)
d
=
f
.
read
()
f
.
close
()
self
.
assertEqual
(
d
,
b"foobar"
)
self
.
assertLessEqual
(
posixpath
.
getctime
(
support
.
TESTFN
),
posixpath
.
getmtime
(
support
.
TESTFN
)
)
finally
:
if
not
f
.
closed
:
f
.
close
()
def
test_islink
(
self
):
self
.
assertIs
(
posixpath
.
islink
(
support
.
TESTFN
+
"1"
),
False
)
f
=
open
(
support
.
TESTFN
+
"1"
,
"wb"
)
...
...
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