Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
64fe5235
Kaydet (Commit)
64fe5235
authored
May 22, 2001
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Convert dospath test suite to PyUnit, adding a couple more cases for
isabs() (no false results were checked) and splitdrive().
üst
876dc70b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
46 deletions
+55
-46
test_dospath.py
Lib/test/test_dospath.py
+55
-46
No files found.
Lib/test/test_dospath.py
Dosyayı görüntüle @
64fe5235
import
dospath
import
os
errors
=
0
def
tester
(
fn
,
wantResult
):
fn
=
fn
.
replace
(
"
\\
"
,
"
\\\\
"
)
gotResult
=
eval
(
fn
)
if
wantResult
!=
gotResult
:
print
"error!"
print
"evaluated: "
+
str
(
fn
)
print
"should be: "
+
str
(
wantResult
)
print
" returned: "
+
str
(
gotResult
)
print
""
global
errors
errors
=
errors
+
1
tester
(
'dospath.splitdrive("c:
\\
foo
\\
bar")'
,
(
'c:'
,
'
\\
foo
\\
bar'
))
tester
(
'dospath.splitdrive("c:/foo/bar")'
,
(
'c:'
,
'/foo/bar'
))
tester
(
'dospath.split("c:
\\
foo
\\
bar")'
,
(
'c:
\\
foo'
,
'bar'
))
tester
(
'dospath.split("
\\\\
conky
\\
mountpoint
\\
foo
\\
bar")'
,
(
'
\\\\
conky
\\
mountpoint
\\
foo'
,
'bar'
))
tester
(
'dospath.split("c:
\\
")'
,
(
'c:
\\
'
,
''
))
tester
(
'dospath.split("
\\\\
conky
\\
mountpoint
\\
")'
,
(
'
\\\\
conky
\\
mountpoint'
,
''
))
tester
(
'dospath.split("c:/")'
,
(
'c:/'
,
''
))
tester
(
'dospath.split("//conky/mountpoint/")'
,
(
'//conky/mountpoint'
,
''
))
tester
(
'dospath.isabs("c:
\\
")'
,
1
)
tester
(
'dospath.isabs("
\\\\
conky
\\
mountpoint
\\
")'
,
1
)
tester
(
'dospath.isabs("
\\
foo")'
,
1
)
tester
(
'dospath.isabs("
\\
foo
\\
bar")'
,
1
)
tester
(
'dospath.abspath("C:
\\
")'
,
"C:
\\
"
)
tester
(
'dospath.commonprefix(["/home/swenson/spam", "/home/swen/spam"])'
,
"/home/swen"
)
tester
(
'dospath.commonprefix(["
\\
home
\\
swen
\\
spam", "
\\
home
\\
swen
\\
eggs"])'
,
"
\\
home
\\
swen
\\
"
)
tester
(
'dospath.commonprefix(["/home/swen/spam", "/home/swen/spam"])'
,
"/home/swen/spam"
)
if
errors
:
print
str
(
errors
)
+
" errors."
else
:
print
"No errors. Thank your lucky stars."
import
test_support
import
unittest
class
DOSPathTestCase
(
unittest
.
TestCase
):
def
test_abspath
(
self
):
self
.
assert_
(
dospath
.
abspath
(
"C:
\\
"
)
==
"C:
\\
"
)
def
test_isabs
(
self
):
isabs
=
dospath
.
isabs
self
.
assert_
(
isabs
(
"c:
\\
"
))
self
.
assert_
(
isabs
(
"
\\\\
conky
\\
mountpoint
\\
"
))
self
.
assert_
(
isabs
(
"
\\
foo"
))
self
.
assert_
(
isabs
(
"
\\
foo
\\
bar"
))
self
.
failIf
(
isabs
(
"foo"
))
self
.
failIf
(
isabs
(
"foo
\\
"
))
self
.
failIf
(
isabs
(
"foo
\\
bar"
))
self
.
failIf
(
isabs
(
"c:foo"
))
self
.
failIf
(
isabs
(
"c:foo
\\
"
))
self
.
failIf
(
isabs
(
"c:foo
\\
bar"
))
def
test_commonprefix
(
self
):
commonprefix
=
dospath
.
commonprefix
self
.
assert_
(
commonprefix
([
"/home/swenson/spam"
,
"/home/swen/spam"
])
==
"/home/swen"
)
self
.
assert_
(
commonprefix
([
"
\\
home
\\
swen
\\
spam"
,
"
\\
home
\\
swen
\\
eggs"
])
==
"
\\
home
\\
swen
\\
"
)
self
.
assert_
(
commonprefix
([
"/home/swen/spam"
,
"/home/swen/spam"
])
==
"/home/swen/spam"
)
def
test_split
(
self
):
split
=
dospath
.
split
self
.
assertEquals
(
split
(
"c:
\\
foo
\\
bar"
),
(
'c:
\\
foo'
,
'bar'
))
self
.
assertEquals
(
split
(
"
\\\\
conky
\\
mountpoint
\\
foo
\\
bar"
),
(
'
\\\\
conky
\\
mountpoint
\\
foo'
,
'bar'
))
self
.
assertEquals
(
split
(
"c:
\\
"
),
(
'c:
\\
'
,
''
))
self
.
assertEquals
(
split
(
"
\\\\
conky
\\
mountpoint
\\
"
),
(
'
\\\\
conky
\\
mountpoint'
,
''
))
self
.
assertEquals
(
split
(
"c:/"
),
(
'c:/'
,
''
))
self
.
assertEquals
(
split
(
"//conky/mountpoint/"
),
(
'//conky/mountpoint'
,
''
))
def
test_splitdrive
(
self
):
splitdrive
=
dospath
.
splitdrive
self
.
assertEquals
(
splitdrive
(
"c:
\\
foo
\\
bar"
),
(
'c:'
,
'
\\
foo
\\
bar'
))
self
.
assertEquals
(
splitdrive
(
"c:/foo/bar"
),
(
'c:'
,
'/foo/bar'
))
self
.
assertEquals
(
splitdrive
(
"foo
\\
bar"
),
(
''
,
'foo
\\
bar'
))
self
.
assertEquals
(
splitdrive
(
"c:"
),
(
'c:'
,
''
))
test_support
.
run_unittest
(
DOSPathTestCase
)
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