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
5424ad8a
Kaydet (Commit)
5424ad8a
authored
Mar 15, 2006
tarafından
Nick Coghlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make test_runpy close all references to test modules before trying to delete the underlying files
üst
21d3a7cd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
test_runpy.py
Lib/test/test_runpy.py
+11
-8
No files found.
Lib/test/test_runpy.py
Dosyayı görüntüle @
5424ad8a
...
...
@@ -113,13 +113,6 @@ class RunModuleTest(unittest.TestCase):
return
pkg_dir
,
mod_fname
,
mod_name
def
_del_pkg
(
self
,
top
,
depth
,
mod_name
):
for
root
,
dirs
,
files
in
os
.
walk
(
top
,
topdown
=
False
):
for
name
in
files
:
os
.
remove
(
os
.
path
.
join
(
root
,
name
))
for
name
in
dirs
:
os
.
rmdir
(
os
.
path
.
join
(
root
,
name
))
os
.
rmdir
(
top
)
if
verbose
:
print
" Removed package tree"
for
i
in
range
(
depth
+
1
):
# Don't forget the module itself
parts
=
mod_name
.
rsplit
(
"."
,
i
)
entry
=
parts
[
0
]
...
...
@@ -127,6 +120,13 @@ class RunModuleTest(unittest.TestCase):
if
verbose
:
print
" Removed sys.modules entries"
del
sys
.
path
[
0
]
if
verbose
:
print
" Removed sys.path entry"
for
root
,
dirs
,
files
in
os
.
walk
(
top
,
topdown
=
False
):
for
name
in
files
:
os
.
remove
(
os
.
path
.
join
(
root
,
name
))
for
name
in
dirs
:
os
.
rmdir
(
os
.
path
.
join
(
root
,
name
))
os
.
rmdir
(
top
)
if
verbose
:
print
" Removed package tree"
def
_check_module
(
self
,
depth
):
pkg_dir
,
mod_fname
,
mod_name
=
(
...
...
@@ -134,13 +134,16 @@ class RunModuleTest(unittest.TestCase):
try
:
if
verbose
:
print
"Running from source:"
,
mod_name
d1
=
run_module
(
mod_name
)
# Read from source
self
.
failUnless
(
d1
[
"x"
]
==
1
)
del
d1
# Ensure __loader__ entry doesn't keep file open
__import__
(
mod_name
)
os
.
remove
(
mod_fname
)
if
verbose
:
print
"Running from compiled:"
,
mod_name
d2
=
run_module
(
mod_name
)
# Read from bytecode
self
.
failUnless
(
d2
[
"x"
]
==
1
)
del
d2
# Ensure __loader__ entry doesn't keep file open
finally
:
self
.
_del_pkg
(
pkg_dir
,
depth
,
mod_name
)
self
.
failUnless
(
d1
[
"x"
]
==
d2
[
"x"
]
==
1
)
if
verbose
:
print
"Module executed successfully"
def
test_run_module
(
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