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
9ca520a0
Kaydet (Commit)
9ca520a0
authored
Ock 28, 2014
tarafından
Gregory P. Smith
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Remove unneeded use of globals() and locals() in test on imports
introduced with the issue19081 tests.
üst
aaef0e78
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
9 deletions
+8
-9
test_zipimport.py
Lib/test/test_zipimport.py
+8
-9
No files found.
Lib/test/test_zipimport.py
Dosyayı görüntüle @
9ca520a0
...
@@ -456,8 +456,7 @@ class ZipFileModifiedAfterImportTestCase(ImportHooksBaseTestCase):
...
@@ -456,8 +456,7 @@ class ZipFileModifiedAfterImportTestCase(ImportHooksBaseTestCase):
# Now that the zipfile has been replaced, import something else from it
# Now that the zipfile has been replaced, import something else from it
# which should fail as the file contents are now garbage.
# which should fail as the file contents are now garbage.
with
self
.
assertRaises
(
ImportError
):
with
self
.
assertRaises
(
ImportError
):
ziptest_a
=
__import__
(
"ziptest_a"
,
globals
(),
locals
(),
ziptest_a
=
__import__
(
"ziptest_a"
,
{},
{},
[
"test_value"
])
[
"test_value"
])
# The code path used by the __import__ call is different than
# The code path used by the __import__ call is different than
# that used by import statements. Try these as well. Some of
# that used by import statements. Try these as well. Some of
# these may create new zipimporter instances. We need to
# these may create new zipimporter instances. We need to
...
@@ -486,9 +485,9 @@ class ZipFileModifiedAfterImportTestCase(ImportHooksBaseTestCase):
...
@@ -486,9 +485,9 @@ class ZipFileModifiedAfterImportTestCase(ImportHooksBaseTestCase):
exec
(
"from {} import {}"
.
format
(
TESTPACK
,
TESTMOD
),
test_ns
)
exec
(
"from {} import {}"
.
format
(
TESTPACK
,
TESTMOD
),
test_ns
)
self
.
assertEqual
(
test_ns
[
TESTMOD
]
.
test_value
,
38
)
self
.
assertEqual
(
test_ns
[
TESTMOD
]
.
test_value
,
38
)
ziptest_a
=
__import__
(
"ziptest_a"
,
globals
(),
locals
()
,
[
"test_value"
])
ziptest_a
=
__import__
(
"ziptest_a"
,
{},
{}
,
[
"test_value"
])
self
.
assertEqual
(
ziptest_a
.
test_value
,
23
)
self
.
assertEqual
(
ziptest_a
.
test_value
,
23
)
ziptest_c
=
__import__
(
"ziptest_c"
,
globals
(),
locals
()
,
[
"test_value"
])
ziptest_c
=
__import__
(
"ziptest_c"
,
{},
{}
,
[
"test_value"
])
self
.
assertEqual
(
ziptest_c
.
test_value
,
1337
)
self
.
assertEqual
(
ziptest_c
.
test_value
,
1337
)
def
testZipFileSubpackageImport
(
self
):
def
testZipFileSubpackageImport
(
self
):
...
@@ -497,7 +496,7 @@ class ZipFileModifiedAfterImportTestCase(ImportHooksBaseTestCase):
...
@@ -497,7 +496,7 @@ class ZipFileModifiedAfterImportTestCase(ImportHooksBaseTestCase):
# Put a subdirectory within the zip file into the import path.
# Put a subdirectory within the zip file into the import path.
sys
.
path
.
insert
(
0
,
self
.
zipfile_path
+
os
.
sep
+
TESTPACK
)
sys
.
path
.
insert
(
0
,
self
.
zipfile_path
+
os
.
sep
+
TESTPACK
)
testmod
=
__import__
(
TESTMOD
,
globals
(),
locals
()
,
[
"test_value"
])
testmod
=
__import__
(
TESTMOD
,
{},
{}
,
[
"test_value"
])
self
.
assertEqual
(
testmod
.
test_value
,
38
)
self
.
assertEqual
(
testmod
.
test_value
,
38
)
del
sys
.
modules
[
TESTMOD
]
del
sys
.
modules
[
TESTMOD
]
test_ns
=
{}
test_ns
=
{}
...
@@ -507,7 +506,7 @@ class ZipFileModifiedAfterImportTestCase(ImportHooksBaseTestCase):
...
@@ -507,7 +506,7 @@ class ZipFileModifiedAfterImportTestCase(ImportHooksBaseTestCase):
# Confirm that imports from the top level of the zip file
# Confirm that imports from the top level of the zip file
# (already in sys.path from the setup call above) still work.
# (already in sys.path from the setup call above) still work.
ziptest_a
=
__import__
(
"ziptest_a"
,
globals
(),
locals
()
,
[
"test_value"
])
ziptest_a
=
__import__
(
"ziptest_a"
,
{},
{}
,
[
"test_value"
])
self
.
assertEqual
(
ziptest_a
.
test_value
,
23
)
self
.
assertEqual
(
ziptest_a
.
test_value
,
23
)
del
sys
.
modules
[
"ziptest_a"
]
del
sys
.
modules
[
"ziptest_a"
]
import
ziptest_c
import
ziptest_c
...
@@ -517,7 +516,7 @@ class ZipFileModifiedAfterImportTestCase(ImportHooksBaseTestCase):
...
@@ -517,7 +516,7 @@ class ZipFileModifiedAfterImportTestCase(ImportHooksBaseTestCase):
self
.
truncateAndFillZipWithNonZipGarbage
()
self
.
truncateAndFillZipWithNonZipGarbage
()
# Imports should now fail.
# Imports should now fail.
with
self
.
assertRaises
(
ImportError
):
with
self
.
assertRaises
(
ImportError
):
testmod
=
__import__
(
TESTMOD
,
globals
(),
locals
()
,
[
"test_value"
])
testmod
=
__import__
(
TESTMOD
,
{},
{}
,
[
"test_value"
])
with
self
.
assertRaises
(
ImportError
):
with
self
.
assertRaises
(
ImportError
):
exec
(
"from {} import test_value"
.
format
(
TESTMOD
),
{})
exec
(
"from {} import test_value"
.
format
(
TESTMOD
),
{})
with
self
.
assertRaises
(
ImportError
):
with
self
.
assertRaises
(
ImportError
):
...
@@ -525,14 +524,14 @@ class ZipFileModifiedAfterImportTestCase(ImportHooksBaseTestCase):
...
@@ -525,14 +524,14 @@ class ZipFileModifiedAfterImportTestCase(ImportHooksBaseTestCase):
self
.
restoreZipFileWithDifferentHeaderOffsets
()
self
.
restoreZipFileWithDifferentHeaderOffsets
()
# Imports should work again, the central directory TOC will be re-read.
# Imports should work again, the central directory TOC will be re-read.
testmod
=
__import__
(
TESTMOD
,
globals
(),
locals
()
,
[
"test_value"
])
testmod
=
__import__
(
TESTMOD
,
{},
{}
,
[
"test_value"
])
self
.
assertEqual
(
testmod
.
test_value
,
38
)
self
.
assertEqual
(
testmod
.
test_value
,
38
)
del
sys
.
modules
[
TESTMOD
]
del
sys
.
modules
[
TESTMOD
]
test_ns
=
{}
test_ns
=
{}
exec
(
"from {} import test_value"
.
format
(
TESTMOD
),
test_ns
)
exec
(
"from {} import test_value"
.
format
(
TESTMOD
),
test_ns
)
self
.
assertEqual
(
test_ns
[
'test_value'
],
38
)
self
.
assertEqual
(
test_ns
[
'test_value'
],
38
)
ziptest_a
=
__import__
(
"ziptest_a"
,
globals
(),
locals
()
,
[
"test_value"
])
ziptest_a
=
__import__
(
"ziptest_a"
,
{},
{}
,
[
"test_value"
])
self
.
assertEqual
(
ziptest_a
.
test_value
,
23
)
self
.
assertEqual
(
ziptest_a
.
test_value
,
23
)
import
ziptest_c
import
ziptest_c
self
.
assertEqual
(
ziptest_c
.
test_value
,
1337
)
self
.
assertEqual
(
ziptest_c
.
test_value
,
1337
)
...
...
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