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
939ea76b
Kaydet (Commit)
939ea76b
authored
Şub 05, 2009
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Begin writing tests for importlib.machinery.PathFinder.
üst
fa3d1fc6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
1 deletion
+57
-1
test_path.py
Lib/importlib/test/import_/test_path.py
+57
-1
No files found.
Lib/importlib/test/import_/test_path.py
Dosyayı görüntüle @
939ea76b
from
importlib
import
machinery
from
..
import
util
from
..
import
util
from
.
import
util
as
import_util
from
.
import
util
as
import_util
from
contextlib
import
nested
from
contextlib
import
nested
...
@@ -149,9 +150,64 @@ class __path__Tests(BaseTests):
...
@@ -149,9 +150,64 @@ class __path__Tests(BaseTests):
self
.
path_argument_test
(
name
)
self
.
path_argument_test
(
name
)
class
FinderTests
(
unittest
.
TestCase
):
"""Tests for SysPathImporter."""
def
test_failure
(
self
):
# Test None returned upon not finding a suitable finder.
def
mock_implicit_hooks
():
return
[]
# XXX Not blackbox.
original_hooks
=
machinery
.
PathFinder
.
_implicit_hooks
machinery
.
PathFinder
.
_implicit_hooks
=
staticmethod
(
mock_implicit_hooks
)
try
:
with
util
.
import_state
():
self
.
assert_
(
machinery
.
PathFinder
.
find_module
(
'XXX'
)
is
None
)
finally
:
machinery
.
PathFinder
.
_implicit_hooks
=
original_hooks
def
test_sys_path
(
self
):
# Test that sys.path is used when 'path' is None.
# Implicitly tests that sys.path_importer_cache is used.
module
=
'<test module>'
path
=
'<test path>'
importer
=
util
.
mock_modules
(
module
)
with
util
.
import_state
(
path_importer_cache
=
{
path
:
importer
},
path
=
[
path
]):
loader
=
machinery
.
PathFinder
.
find_module
(
module
)
self
.
assert_
(
loader
is
importer
)
def
test_path
(
self
):
# Test that 'path' is used when set.
# Implicitly tests that sys.path_importer_cache is used.
module
=
'<test module>'
path
=
'<test path>'
importer
=
util
.
mock_modules
(
module
)
with
util
.
import_state
(
path_importer_cache
=
{
path
:
importer
}):
loader
=
machinery
.
PathFinder
.
find_module
(
module
,
[
path
])
self
.
assert_
(
loader
is
importer
)
def
test_path_importer_cache_has_None
(
self
):
# Test that the default hook is used when sys.path_importer_cache
# contains None for a path.
# TODO(brett.cannon) implement
pass
def
test_path_hooks
(
self
):
# Test that sys.path_hooks is used.
# TODO(brett.cannon) implement
pass
def
test_implicit_hooks
(
self
):
# Test that the implicit path hooks are used.
# TODO(brett.cannon) implement
pass
def
test_main
():
def
test_main
():
from
test.support
import
run_unittest
from
test.support
import
run_unittest
run_unittest
(
PathTests
,
__path__Tests
)
run_unittest
(
PathTests
,
__path__Tests
,
FinderTests
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
test_main
()
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