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
6411aa5d
Kaydet (Commit)
6411aa5d
authored
Şub 06, 2009
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Finish implementing tests for importlib.machinery.PathFinder by testing that
implicit hooks are handled properly.
üst
1f9bcd38
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
14 deletions
+31
-14
NOTES
Lib/importlib/NOTES
+12
-10
test_path.py
Lib/importlib/test/import_/test_path.py
+19
-4
No files found.
Lib/importlib/NOTES
Dosyayı görüntüle @
6411aa5d
...
...
@@ -9,11 +9,15 @@ to do
* Create meta_path importer for sys.path.
+ Create hook.
+ Write tests.
+ Rewrite Import to use the hook.
+ Document.
* Refactor __import__.
+ Create a greatest common denominator function for __import__/import_module
that takes in an absolute module name and performs the import.
+ Use GCD import for __import__.
+ Use GCD import for import_module.
* Implement PEP 302 protocol for loaders (should just be a matter of testing).
+ Built-in.
...
...
@@ -21,7 +25,7 @@ to do
+ Extension.
+ Source/bytecode.
* Public API to expose (w/ docs!)
* Public API
left
to expose (w/ docs!)
+ abc
...
...
@@ -33,6 +37,8 @@ to do
* load_module
- (?) Importer(Finder, Loader)
- ResourceLoader(Loader)
* get_data
...
...
@@ -58,8 +64,6 @@ to do
+ machinery
- (?) Chained path hook/finder
- BuiltinImporter
- FrozenImporter
- (?) FileFinder
- Extensions importers
...
...
@@ -75,10 +79,8 @@ to do
* OPTIMIZE!
+ Fast path common cases.
- Absolute name from sys.path.
- Relative name from sys.path.
+ Fast path absolute name.
+ Fast path pulling from sys.modules.
* Bootstrap importlib as implementation of builtins.__import__
...
...
Lib/importlib/test/import_/test_path.py
Dosyayı görüntüle @
6411aa5d
...
...
@@ -2,9 +2,10 @@ from importlib import machinery
from
..
import
util
from
.
import
util
as
import_util
from
contextlib
import
nested
from
imp
import
new_module
import
imp
import
os
import
sys
from
test
import
support
from
types
import
MethodType
import
unittest
...
...
@@ -143,7 +144,7 @@ class __path__Tests(BaseTests):
self
.
run_test
(
self
.
hooks_order_test
,
location
,
[
location
])
def
test_path_argument
(
self
):
module
=
new_module
(
'pkg'
)
module
=
imp
.
new_module
(
'pkg'
)
module
.
__path__
=
[
'random __path__'
]
name
=
'pkg.whatever'
sys
.
modules
[
'pkg'
]
=
module
...
...
@@ -221,8 +222,22 @@ class FinderTests(unittest.TestCase):
def
test_implicit_hooks
(
self
):
# Test that the implicit path hooks are used.
# TODO(brett.cannon) implement
pass
existing_path
=
os
.
path
.
dirname
(
support
.
TESTFN
)
bad_path
=
'<path>'
module
=
'<module>'
assert
not
os
.
path
.
exists
(
bad_path
)
with
util
.
import_state
():
nothing
=
machinery
.
PathFinder
.
find_module
(
module
,
path
=
[
existing_path
])
self
.
assert_
(
nothing
is
None
)
self
.
assert_
(
existing_path
in
sys
.
path_importer_cache
)
self
.
assert_
(
not
isinstance
(
sys
.
path_importer_cache
[
existing_path
],
imp
.
NullImporter
))
nothing
=
machinery
.
PathFinder
.
find_module
(
module
,
path
=
[
bad_path
])
self
.
assert_
(
nothing
is
None
)
self
.
assert_
(
bad_path
in
sys
.
path_importer_cache
)
self
.
assert_
(
isinstance
(
sys
.
path_importer_cache
[
bad_path
],
imp
.
NullImporter
))
def
test_main
():
...
...
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