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
d65018b1
Kaydet (Commit)
d65018b1
authored
May 10, 2016
tarafından
Eric Snow
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixes #19711: Add tests for reloading namespace packages.
üst
c499f302
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletion
+35
-1
test_namespace_pkgs.py
Lib/test/test_importlib/test_namespace_pkgs.py
+33
-1
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_importlib/test_namespace_pkgs.py
Dosyayı görüntüle @
d65018b1
import
contextlib
import
importlib
import
os
import
sys
import
unittest
...
...
@@ -67,6 +68,7 @@ class NamespacePackageTest(unittest.TestCase):
# TODO: will we ever want to pass exc_info to __exit__?
self
.
ctx
.
__exit__
(
None
,
None
,
None
)
class
SingleNamespacePackage
(
NamespacePackageTest
):
paths
=
[
'portion1'
]
...
...
@@ -83,7 +85,7 @@ class SingleNamespacePackage(NamespacePackageTest):
self
.
assertEqual
(
repr
(
foo
),
"<module 'foo' (namespace)>"
)
class
DynamicPath
e
NamespacePackage
(
NamespacePackageTest
):
class
DynamicPathNamespacePackage
(
NamespacePackageTest
):
paths
=
[
'portion1'
]
def
test_dynamic_path
(
self
):
...
...
@@ -285,5 +287,35 @@ class ModuleAndNamespacePackageInSameDir(NamespacePackageTest):
self
.
assertEqual
(
a_test
.
attr
,
'in module'
)
class
ReloadTests
(
NamespacePackageTest
):
paths
=
[
'portion1'
]
def
test_simple_package
(
self
):
import
foo.one
foo
=
importlib
.
reload
(
foo
)
self
.
assertEqual
(
foo
.
one
.
attr
,
'portion1 foo one'
)
def
test_cant_import_other
(
self
):
import
foo
with
self
.
assertRaises
(
ImportError
):
import
foo.two
foo
=
importlib
.
reload
(
foo
)
with
self
.
assertRaises
(
ImportError
):
import
foo.two
def
test_dynamic_path
(
self
):
import
foo.one
with
self
.
assertRaises
(
ImportError
):
import
foo.two
# Now modify sys.path and reload.
sys
.
path
.
append
(
os
.
path
.
join
(
self
.
root
,
'portion2'
))
foo
=
importlib
.
reload
(
foo
)
# And make sure foo.two is now importable
import
foo.two
self
.
assertEqual
(
foo
.
two
.
attr
,
'portion2 foo two'
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Misc/NEWS
Dosyayı görüntüle @
d65018b1
...
...
@@ -52,6 +52,8 @@ Core and Builtins
- Issue #26581: If coding cookie is specified multiple times on a line in
Python source code file, only the first one is taken to account.
- Issue #19711: Add tests for reloading namespace packages.
- Issue #26563: Debug hooks on Python memory allocators now raise a fatal
error if functions of the :c:func:`PyMem_Malloc` family are called without
holding the GIL.
...
...
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