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
18ffe42b
Kaydet (Commit)
18ffe42b
authored
Nis 04, 2007
tarafından
Žiga Seilnacht
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix WalkTests.test_traversal() on Windows. The cleanup in
MakedirTests.setUp() can now be removed.
üst
10fe4555
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
25 deletions
+18
-25
test_os.py
Lib/test/test_os.py
+18
-25
No files found.
Lib/test/test_os.py
Dosyayı görüntüle @
18ffe42b
...
@@ -313,9 +313,9 @@ class WalkTests(unittest.TestCase):
...
@@ -313,9 +313,9 @@ class WalkTests(unittest.TestCase):
f
.
close
()
f
.
close
()
if
hasattr
(
os
,
"symlink"
):
if
hasattr
(
os
,
"symlink"
):
os
.
symlink
(
os
.
path
.
abspath
(
t2_path
),
link_path
)
os
.
symlink
(
os
.
path
.
abspath
(
t2_path
),
link_path
)
sub2_tree
=
(
sub2_path
,
[
"link"
],
[
"tmp3"
])
else
:
else
:
# it must be a directory because the test expects that
sub2_tree
=
(
sub2_path
,
[],
[
"tmp3"
])
os
.
mkdir
(
link_path
)
# Walk top-down.
# Walk top-down.
all
=
list
(
os
.
walk
(
walk_path
))
all
=
list
(
os
.
walk
(
walk_path
))
...
@@ -328,7 +328,7 @@ class WalkTests(unittest.TestCase):
...
@@ -328,7 +328,7 @@ class WalkTests(unittest.TestCase):
self
.
assertEqual
(
all
[
0
],
(
walk_path
,
[
"SUB1"
,
"SUB2"
],
[
"tmp1"
]))
self
.
assertEqual
(
all
[
0
],
(
walk_path
,
[
"SUB1"
,
"SUB2"
],
[
"tmp1"
]))
self
.
assertEqual
(
all
[
1
+
flipped
],
(
sub1_path
,
[
"SUB11"
],
[
"tmp2"
]))
self
.
assertEqual
(
all
[
1
+
flipped
],
(
sub1_path
,
[
"SUB11"
],
[
"tmp2"
]))
self
.
assertEqual
(
all
[
2
+
flipped
],
(
sub11_path
,
[],
[]))
self
.
assertEqual
(
all
[
2
+
flipped
],
(
sub11_path
,
[],
[]))
self
.
assertEqual
(
all
[
3
-
2
*
flipped
],
(
sub2_path
,
[
"link"
],
[
"tmp3"
])
)
self
.
assertEqual
(
all
[
3
-
2
*
flipped
],
sub2_tree
)
# Prune the search.
# Prune the search.
all
=
[]
all
=
[]
...
@@ -340,7 +340,7 @@ class WalkTests(unittest.TestCase):
...
@@ -340,7 +340,7 @@ class WalkTests(unittest.TestCase):
dirs
.
remove
(
'SUB1'
)
dirs
.
remove
(
'SUB1'
)
self
.
assertEqual
(
len
(
all
),
2
)
self
.
assertEqual
(
len
(
all
),
2
)
self
.
assertEqual
(
all
[
0
],
(
walk_path
,
[
"SUB2"
],
[
"tmp1"
]))
self
.
assertEqual
(
all
[
0
],
(
walk_path
,
[
"SUB2"
],
[
"tmp1"
]))
self
.
assertEqual
(
all
[
1
],
(
sub2_path
,
[
"link"
],
[
"tmp3"
])
)
self
.
assertEqual
(
all
[
1
],
sub2_tree
)
# Walk bottom-up.
# Walk bottom-up.
all
=
list
(
os
.
walk
(
walk_path
,
topdown
=
False
))
all
=
list
(
os
.
walk
(
walk_path
,
topdown
=
False
))
...
@@ -353,27 +353,28 @@ class WalkTests(unittest.TestCase):
...
@@ -353,27 +353,28 @@ class WalkTests(unittest.TestCase):
self
.
assertEqual
(
all
[
3
],
(
walk_path
,
[
"SUB1"
,
"SUB2"
],
[
"tmp1"
]))
self
.
assertEqual
(
all
[
3
],
(
walk_path
,
[
"SUB1"
,
"SUB2"
],
[
"tmp1"
]))
self
.
assertEqual
(
all
[
flipped
],
(
sub11_path
,
[],
[]))
self
.
assertEqual
(
all
[
flipped
],
(
sub11_path
,
[],
[]))
self
.
assertEqual
(
all
[
flipped
+
1
],
(
sub1_path
,
[
"SUB11"
],
[
"tmp2"
]))
self
.
assertEqual
(
all
[
flipped
+
1
],
(
sub1_path
,
[
"SUB11"
],
[
"tmp2"
]))
self
.
assertEqual
(
all
[
2
-
2
*
flipped
],
(
sub2_path
,
[
"link"
],
[
"tmp3"
])
)
self
.
assertEqual
(
all
[
2
-
2
*
flipped
],
sub2_tree
)
# Walk, following symlinks.
if
hasattr
(
os
,
"symlink"
):
for
root
,
dirs
,
files
in
os
.
walk
(
walk_path
,
followlinks
=
True
):
# Walk, following symlinks.
if
root
==
link_path
:
for
root
,
dirs
,
files
in
os
.
walk
(
walk_path
,
followlinks
=
True
)
:
self
.
assertEqual
(
dirs
,
[])
if
root
==
link_path
:
self
.
assertEqual
(
files
,
[
"tmp4"
])
self
.
assertEqual
(
dirs
,
[
])
break
self
.
assertEqual
(
files
,
[
"tmp4"
])
else
:
break
self
.
fail
(
"Didn't follow symlink with followlinks=True"
)
else
:
self
.
fail
(
"Didn't follow symlink with followlinks=True"
)
def
tearDown
(
self
):
# Tear everything down. This is a decent use for bottom-up on
# Tear everything down. This is a decent use for bottom-up on
# Windows, which doesn't have a recursive delete command. The
# Windows, which doesn't have a recursive delete command. The
# (not so) subtlety is that rmdir will fail unless the dir's
# (not so) subtlety is that rmdir will fail unless the dir's
# kids are removed first, so bottom up is essential.
# kids are removed first, so bottom up is essential.
for
root
,
dirs
,
files
in
os
.
walk
(
test_support
.
TESTFN
,
topdown
=
False
):
for
root
,
dirs
,
files
in
os
.
walk
(
test_support
.
TESTFN
,
topdown
=
False
):
for
name
in
files
:
for
name
in
files
:
os
.
remove
(
join
(
root
,
name
))
os
.
remove
(
os
.
path
.
join
(
root
,
name
))
for
name
in
dirs
:
for
name
in
dirs
:
dirname
=
join
(
root
,
name
)
dirname
=
os
.
path
.
join
(
root
,
name
)
if
not
os
.
path
.
islink
(
dirname
):
if
not
os
.
path
.
islink
(
dirname
):
os
.
rmdir
(
dirname
)
os
.
rmdir
(
dirname
)
else
:
else
:
...
@@ -382,14 +383,6 @@ class WalkTests(unittest.TestCase):
...
@@ -382,14 +383,6 @@ class WalkTests(unittest.TestCase):
class
MakedirTests
(
unittest
.
TestCase
):
class
MakedirTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
try
:
os
.
rmdir
(
test_support
.
TESTFN
)
except
OSError
:
pass
try
:
os
.
unlink
(
test_support
.
TESTFN
)
except
OSError
:
pass
os
.
mkdir
(
test_support
.
TESTFN
)
os
.
mkdir
(
test_support
.
TESTFN
)
def
test_makedir
(
self
):
def
test_makedir
(
self
):
...
...
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