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
749afa95
Kaydet (Commit)
749afa95
authored
Eki 29, 2010
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Move test_imp over to file context managers.
üst
105df5d7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
test_imp.py
Lib/test/test_imp.py
+23
-23
No files found.
Lib/test/test_imp.py
Dosyayı görüntüle @
749afa95
...
@@ -55,27 +55,27 @@ class ImportTests(unittest.TestCase):
...
@@ -55,27 +55,27 @@ class ImportTests(unittest.TestCase):
def
test_find_module_encoding
(
self
):
def
test_find_module_encoding
(
self
):
for
mod
,
encoding
,
_
in
self
.
test_strings
:
for
mod
,
encoding
,
_
in
self
.
test_strings
:
fd
=
imp
.
find_module
(
'module_'
+
mod
,
self
.
test_path
)[
0
]
with
imp
.
find_module
(
'module_'
+
mod
,
self
.
test_path
)[
0
]
as
fd
:
self
.
assertEqual
(
fd
.
encoding
,
encoding
)
self
.
assertEqual
(
fd
.
encoding
,
encoding
)
def
test_issue1267
(
self
):
def
test_issue1267
(
self
):
for
mod
,
encoding
,
_
in
self
.
test_strings
:
for
mod
,
encoding
,
_
in
self
.
test_strings
:
fp
,
filename
,
info
=
imp
.
find_module
(
'module_'
+
mod
,
fp
,
filename
,
info
=
imp
.
find_module
(
'module_'
+
mod
,
self
.
test_path
)
self
.
test_path
)
self
.
assertNotEqual
(
fp
,
None
)
with
fp
:
self
.
assertEqual
(
fp
.
encoding
,
encoding
)
self
.
assertNotEqual
(
fp
,
None
)
self
.
assertEqual
(
fp
.
tell
(),
0
)
self
.
assertEqual
(
fp
.
encoding
,
encoding
)
self
.
assertEqual
(
fp
.
readline
(),
'# test
%
s encoding
\n
'
self
.
assertEqual
(
fp
.
tell
(),
0
)
%
encoding
)
self
.
assertEqual
(
fp
.
readline
(),
'# test
%
s encoding
\n
'
fp
.
close
(
)
%
encoding
)
fp
,
filename
,
info
=
imp
.
find_module
(
"tokenize"
)
fp
,
filename
,
info
=
imp
.
find_module
(
"tokenize"
)
self
.
assertNotEqual
(
fp
,
None
)
with
fp
:
self
.
assertEqual
(
fp
.
encoding
,
"utf-8"
)
self
.
assertNotEqual
(
fp
,
None
)
self
.
assertEqual
(
fp
.
tell
(),
0
)
self
.
assertEqual
(
fp
.
encoding
,
"utf-8"
)
self
.
assertEqual
(
fp
.
readline
(),
self
.
assertEqual
(
fp
.
tell
(),
0
)
'"""Tokenization help for Python programs.
\n
'
)
self
.
assertEqual
(
fp
.
readline
(),
fp
.
close
(
)
'"""Tokenization help for Python programs.
\n
'
)
def
test_issue3594
(
self
):
def
test_issue3594
(
self
):
temp_mod_name
=
'test_imp_helper'
temp_mod_name
=
'test_imp_helper'
...
@@ -140,15 +140,15 @@ class ImportTests(unittest.TestCase):
...
@@ -140,15 +140,15 @@ class ImportTests(unittest.TestCase):
with
open
(
temp_mod_name
+
'.py'
,
'w'
)
as
file
:
with
open
(
temp_mod_name
+
'.py'
,
'w'
)
as
file
:
file
.
write
(
'a = 1
\n
'
)
file
.
write
(
'a = 1
\n
'
)
file
,
filename
,
info
=
imp
.
find_module
(
temp_mod_name
)
file
,
filename
,
info
=
imp
.
find_module
(
temp_mod_name
)
self
.
assertIsNotNone
(
file
)
with
file
:
self
.
assertTrue
(
filename
[:
-
3
]
.
endswith
(
temp_mod_name
)
)
self
.
assertIsNotNone
(
file
)
self
.
assertEqual
(
info
[
0
],
'.py'
)
self
.
assertTrue
(
filename
[:
-
3
]
.
endswith
(
temp_mod_name
)
)
self
.
assertEqual
(
info
[
1
],
'U
'
)
self
.
assertEqual
(
info
[
0
],
'.py
'
)
self
.
assertEqual
(
info
[
2
],
imp
.
PY_SOURCE
)
self
.
assertEqual
(
info
[
1
],
'U'
)
self
.
assertEqual
(
info
[
2
],
imp
.
PY_SOURCE
)
mod
=
imp
.
load_module
(
temp_mod_name
,
file
,
filename
,
info
)
self
.
assertEqual
(
mod
.
a
,
1
)
mod
=
imp
.
load_module
(
temp_mod_name
,
file
,
filename
,
info
)
file
.
close
(
)
self
.
assertEqual
(
mod
.
a
,
1
)
mod
=
imp
.
load_source
(
temp_mod_name
,
temp_mod_name
+
'.py'
)
mod
=
imp
.
load_source
(
temp_mod_name
,
temp_mod_name
+
'.py'
)
self
.
assertEqual
(
mod
.
a
,
1
)
self
.
assertEqual
(
mod
.
a
,
1
)
...
...
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