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
534b2cd1
Kaydet (Commit)
534b2cd1
authored
Şub 07, 2009
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Factor out helper code from importlib.test.extension.test_path_hook.
üst
36d1f3eb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
42 deletions
+21
-42
NOTES
Lib/importlib/NOTES
+0
-2
test_case_sensitivity.py
Lib/importlib/test/extension/test_case_sensitivity.py
+3
-3
test_finder.py
Lib/importlib/test/extension/test_finder.py
+3
-3
test_loader.py
Lib/importlib/test/extension/test_loader.py
+11
-12
test_path_hook.py
Lib/importlib/test/extension/test_path_hook.py
+2
-21
util.py
Lib/importlib/test/util.py
+2
-1
No files found.
Lib/importlib/NOTES
Dosyayı görüntüle @
534b2cd1
to do
to do
/////
/////
* Extract test_path_hooks constants into a util module for extension testing.
* Backport a poor-man's functools.wraps.
* Backport a poor-man's functools.wraps.
* Implement PEP 302 protocol for loaders (should just be a matter of testing).
* Implement PEP 302 protocol for loaders (should just be a matter of testing).
...
...
Lib/importlib/test/extension/test_case_sensitivity.py
Dosyayı görüntüle @
534b2cd1
...
@@ -3,17 +3,17 @@ from test import support
...
@@ -3,17 +3,17 @@ from test import support
import
unittest
import
unittest
import
importlib
import
importlib
from
..
import
util
from
..
import
util
from
.
import
test_path_hook
from
.
import
util
as
ext_util
@util.case_insensitive_tests
@util.case_insensitive_tests
class
ExtensionModuleCaseSensitivityTest
(
unittest
.
TestCase
):
class
ExtensionModuleCaseSensitivityTest
(
unittest
.
TestCase
):
def
find_module
(
self
):
def
find_module
(
self
):
good_name
=
test_path_hook
.
NAME
good_name
=
ext_util
.
NAME
bad_name
=
good_name
.
upper
()
bad_name
=
good_name
.
upper
()
assert
good_name
!=
bad_name
assert
good_name
!=
bad_name
finder
=
importlib
.
ExtensionFileImporter
(
test_path_hook
.
PATH
)
finder
=
importlib
.
ExtensionFileImporter
(
ext_util
.
PATH
)
return
finder
.
find_module
(
bad_name
)
return
finder
.
find_module
(
bad_name
)
def
test_case_sensitive
(
self
):
def
test_case_sensitive
(
self
):
...
...
Lib/importlib/test/extension/test_finder.py
Dosyayı görüntüle @
534b2cd1
import
importlib
import
importlib
from
..
import
abc
from
..
import
abc
from
.
import
test_path_hook
from
.
import
util
import
unittest
import
unittest
...
@@ -9,11 +9,11 @@ class FinderTests(abc.FinderTests):
...
@@ -9,11 +9,11 @@ class FinderTests(abc.FinderTests):
"""Test the finder for extension modules."""
"""Test the finder for extension modules."""
def
find_module
(
self
,
fullname
):
def
find_module
(
self
,
fullname
):
importer
=
importlib
.
ExtensionFileImporter
(
test_path_hook
.
PATH
)
importer
=
importlib
.
ExtensionFileImporter
(
util
.
PATH
)
return
importer
.
find_module
(
fullname
)
return
importer
.
find_module
(
fullname
)
def
test_module
(
self
):
def
test_module
(
self
):
self
.
assert_
(
self
.
find_module
(
test_path_hook
.
NAME
))
self
.
assert_
(
self
.
find_module
(
util
.
NAME
))
def
test_package
(
self
):
def
test_package
(
self
):
# Extension modules cannot be an __init__ for a package.
# Extension modules cannot be an __init__ for a package.
...
...
Lib/importlib/test/extension/test_loader.py
Dosyayı görüntüle @
534b2cd1
import
importlib
import
importlib
from
.
import
test_path_hook
from
.
import
util
as
ext_util
from
..
import
abc
from
..
import
abc
from
..
import
util
from
..
import
util
...
@@ -12,19 +12,18 @@ class LoaderTests(abc.LoaderTests):
...
@@ -12,19 +12,18 @@ class LoaderTests(abc.LoaderTests):
"""Test load_module() for extension modules."""
"""Test load_module() for extension modules."""
def
load_module
(
self
,
fullname
):
def
load_module
(
self
,
fullname
):
loader
=
importlib
.
_ExtensionFileLoader
(
test_path_hook
.
NAME
,
loader
=
importlib
.
_ExtensionFileLoader
(
ext_util
.
NAME
,
test_path_hook
.
FILEPATH
,
ext_util
.
FILEPATH
,
False
)
False
)
return
loader
.
load_module
(
fullname
)
return
loader
.
load_module
(
fullname
)
def
test_module
(
self
):
def
test_module
(
self
):
with
util
.
uncache
(
test_path_hook
.
NAME
):
with
util
.
uncache
(
ext_util
.
NAME
):
module
=
self
.
load_module
(
test_path_hook
.
NAME
)
module
=
self
.
load_module
(
ext_util
.
NAME
)
for
attr
,
value
in
[(
'__name__'
,
test_path_hook
.
NAME
),
for
attr
,
value
in
[(
'__name__'
,
ext_util
.
NAME
),
(
'__file__'
,
test_path_hook
.
FILEPATH
),
(
'__file__'
,
ext_util
.
FILEPATH
),
(
'__package__'
,
''
)]:
(
'__package__'
,
''
)]:
self
.
assertEqual
(
getattr
(
module
,
attr
),
value
)
self
.
assertEqual
(
getattr
(
module
,
attr
),
value
)
self
.
assert_
(
test_path_hook
.
NAME
in
sys
.
modules
)
self
.
assert_
(
ext_util
.
NAME
in
sys
.
modules
)
def
test_package
(
self
):
def
test_package
(
self
):
# Extensions are not found in packages.
# Extensions are not found in packages.
...
@@ -35,9 +34,9 @@ class LoaderTests(abc.LoaderTests):
...
@@ -35,9 +34,9 @@ class LoaderTests(abc.LoaderTests):
pass
pass
def
test_module_reuse
(
self
):
def
test_module_reuse
(
self
):
with
util
.
uncache
(
test_path_hook
.
NAME
):
with
util
.
uncache
(
ext_util
.
NAME
):
module1
=
self
.
load_module
(
test_path_hook
.
NAME
)
module1
=
self
.
load_module
(
ext_util
.
NAME
)
module2
=
self
.
load_module
(
test_path_hook
.
NAME
)
module2
=
self
.
load_module
(
ext_util
.
NAME
)
self
.
assert_
(
module1
is
module2
)
self
.
assert_
(
module1
is
module2
)
def
test_state_after_failure
(
self
):
def
test_state_after_failure
(
self
):
...
...
Lib/importlib/test/extension/test_path_hook.py
Dosyayı görüntüle @
534b2cd1
import
importlib
import
importlib
from
.
import
util
import
collections
import
collections
import
imp
import
imp
from
os
import
path
import
sys
import
sys
import
unittest
import
unittest
PATH
=
None
EXT
=
None
FILENAME
=
None
NAME
=
'_testcapi'
_file_exts
=
[
x
[
0
]
for
x
in
imp
.
get_suffixes
()
if
x
[
2
]
==
imp
.
C_EXTENSION
]
try
:
for
PATH
in
sys
.
path
:
for
EXT
in
_file_exts
:
FILENAME
=
NAME
+
EXT
FILEPATH
=
path
.
join
(
PATH
,
FILENAME
)
if
path
.
exists
(
path
.
join
(
PATH
,
FILENAME
)):
raise
StopIteration
else
:
PATH
=
EXT
=
FILENAME
=
FILEPATH
=
None
except
StopIteration
:
pass
del
_file_exts
class
PathHookTests
(
unittest
.
TestCase
):
class
PathHookTests
(
unittest
.
TestCase
):
"""Test the path hook for extension modules."""
"""Test the path hook for extension modules."""
...
@@ -38,7 +19,7 @@ class PathHookTests(unittest.TestCase):
...
@@ -38,7 +19,7 @@ class PathHookTests(unittest.TestCase):
def
test_success
(
self
):
def
test_success
(
self
):
# Path hook should handle a directory where a known extension module
# Path hook should handle a directory where a known extension module
# exists.
# exists.
self
.
assert_
(
hasattr
(
self
.
hook
(
PATH
),
'find_module'
))
self
.
assert_
(
hasattr
(
self
.
hook
(
util
.
PATH
),
'find_module'
))
def
test_main
():
def
test_main
():
...
...
Lib/importlib/test/util.py
Dosyayı görüntüle @
534b2cd1
...
@@ -2,6 +2,7 @@ from contextlib import contextmanager
...
@@ -2,6 +2,7 @@ from contextlib import contextmanager
import
imp
import
imp
import
os.path
import
os.path
from
test.support
import
unlink
from
test.support
import
unlink
import
unittest
import
sys
import
sys
...
@@ -9,7 +10,7 @@ def case_insensitive_tests(class_):
...
@@ -9,7 +10,7 @@ def case_insensitive_tests(class_):
"""Class decorator that nullifies tests that require a case-insensitive
"""Class decorator that nullifies tests that require a case-insensitive
file system."""
file system."""
if
sys
.
platform
not
in
(
'win32'
,
'darwin'
,
'cygwin'
):
if
sys
.
platform
not
in
(
'win32'
,
'darwin'
,
'cygwin'
):
return
object
()
return
unittest
.
TestCase
else
:
else
:
return
class_
return
class_
...
...
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