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
0e7dbe90
Kaydet (Commit)
0e7dbe90
authored
Kas 20, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #28666: Now test.support.rmtree is able to remove unwritable or
unreadable directories.
üst
92b9a1f9
6770f8a4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
13 deletions
+57
-13
__init__.py
Lib/test/support/__init__.py
+31
-1
test_support.py
Lib/test/test_support.py
+23
-12
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/support/__init__.py
Dosyayı görüntüle @
0e7dbe90
...
...
@@ -358,7 +358,37 @@ if sys.platform.startswith("win"):
else
:
_unlink
=
os
.
unlink
_rmdir
=
os
.
rmdir
_rmtree
=
shutil
.
rmtree
def
_rmtree
(
path
):
try
:
shutil
.
rmtree
(
path
)
return
except
OSError
:
pass
def
force_run
(
path
,
func
,
*
args
):
try
:
return
func
(
*
args
)
except
OSError
as
err
:
if
verbose
>=
2
:
print
(
'
%
s:
%
s'
%
(
err
.
__class__
.
__name__
,
err
))
print
(
're-run
%
s
%
r'
%
(
func
.
__name__
,
args
))
os
.
chmod
(
path
,
stat
.
S_IRWXU
)
return
func
(
*
args
)
def
_rmtree_inner
(
path
):
for
name
in
force_run
(
path
,
os
.
listdir
,
path
):
fullname
=
os
.
path
.
join
(
path
,
name
)
try
:
mode
=
os
.
lstat
(
fullname
)
.
st_mode
except
OSError
:
mode
=
0
if
stat
.
S_ISDIR
(
mode
):
_rmtree_inner
(
fullname
)
force_run
(
path
,
os
.
rmdir
,
fullname
)
else
:
force_run
(
path
,
os
.
unlink
,
fullname
)
_rmtree_inner
(
path
)
os
.
rmdir
(
path
)
def
unlink
(
filename
):
try
:
...
...
Lib/test/test_support.py
Dosyayı görüntüle @
0e7dbe90
import
importlib
import
shutil
import
stat
import
sys
import
os
import
unittest
...
...
@@ -12,9 +13,6 @@ TESTFN = support.TESTFN
class
TestSupport
(
unittest
.
TestCase
):
def
setUp
(
self
):
support
.
unlink
(
TESTFN
)
tearDown
=
setUp
def
test_import_module
(
self
):
support
.
import_module
(
"ftplib"
)
...
...
@@ -46,15 +44,28 @@ class TestSupport(unittest.TestCase):
support
.
unlink
(
TESTFN
)
def
test_rmtree
(
self
):
TESTDIRN
=
os
.
path
.
basename
(
tempfile
.
mkdtemp
(
dir
=
'.'
))
self
.
addCleanup
(
support
.
rmtree
,
TESTDIRN
)
support
.
rmtree
(
TESTDIRN
)
os
.
mkdir
(
TESTDIRN
)
os
.
mkdir
(
os
.
path
.
join
(
TESTDIRN
,
TESTDIRN
))
support
.
rmtree
(
TESTDIRN
)
self
.
assertFalse
(
os
.
path
.
exists
(
TESTDIRN
))
support
.
rmtree
(
TESTDIRN
)
dirpath
=
support
.
TESTFN
+
'd'
subdirpath
=
os
.
path
.
join
(
dirpath
,
'subdir'
)
os
.
mkdir
(
dirpath
)
os
.
mkdir
(
subdirpath
)
support
.
rmtree
(
dirpath
)
self
.
assertFalse
(
os
.
path
.
exists
(
dirpath
))
with
support
.
swap_attr
(
support
,
'verbose'
,
0
):
support
.
rmtree
(
dirpath
)
os
.
mkdir
(
dirpath
)
os
.
mkdir
(
subdirpath
)
os
.
chmod
(
dirpath
,
stat
.
S_IRUSR
|
stat
.
S_IXUSR
)
with
support
.
swap_attr
(
support
,
'verbose'
,
0
):
support
.
rmtree
(
dirpath
)
self
.
assertFalse
(
os
.
path
.
exists
(
dirpath
))
os
.
mkdir
(
dirpath
)
os
.
mkdir
(
subdirpath
)
os
.
chmod
(
dirpath
,
0
)
with
support
.
swap_attr
(
support
,
'verbose'
,
0
):
support
.
rmtree
(
dirpath
)
self
.
assertFalse
(
os
.
path
.
exists
(
dirpath
))
def
test_forget
(
self
):
mod_filename
=
TESTFN
+
'.py'
...
...
Misc/NEWS
Dosyayı görüntüle @
0e7dbe90
...
...
@@ -82,6 +82,9 @@ Documentation
Tests
-----
- Issue #28666: Now test.support.rmtree is able to remove unwritable or
unreadable directories.
- Issue #23839: Various caches now are cleared before running every test file.
Build
...
...
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