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
3cf74384
Kaydet (Commit)
3cf74384
authored
Ara 07, 2018
tarafından
Anirudha Bose
Kaydeden (comit)
Brett Cannon
Ara 07, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-33747: Avoid mutating the global sys.modules dict in unittest.mock tests (GH-8520)
üst
028f0ef4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
testpatch.py
Lib/unittest/test/testmock/testpatch.py
+16
-11
No files found.
Lib/unittest/test/testmock/testpatch.py
Dosyayı görüntüle @
3cf74384
...
...
@@ -9,6 +9,7 @@ import unittest
from
unittest.test.testmock
import
support
from
unittest.test.testmock.support
import
SomeClass
,
is_instance
from
test.test_importlib.util
import
uncache
from
unittest.mock
import
(
NonCallableMock
,
CallableMixin
,
sentinel
,
MagicMock
,
Mock
,
NonCallableMagicMock
,
patch
,
_patch
,
...
...
@@ -1660,20 +1661,19 @@ class PatchTest(unittest.TestCase):
def
test_patch_imports_lazily
(
self
):
sys
.
modules
.
pop
(
'squizz'
,
None
)
p1
=
patch
(
'squizz.squozz'
)
self
.
assertRaises
(
ImportError
,
p1
.
start
)
squizz
=
Mock
()
squizz
.
squozz
=
6
sys
.
modules
[
'squizz'
]
=
squizz
p1
=
patch
(
'squizz.squozz'
)
squizz
.
squozz
=
3
p1
.
start
()
p1
.
stop
()
self
.
assertEqual
(
squizz
.
squozz
,
3
)
with
uncache
(
'squizz'
):
squizz
=
Mock
()
sys
.
modules
[
'squizz'
]
=
squizz
squizz
.
squozz
=
6
p1
=
patch
(
'squizz.squozz'
)
squizz
.
squozz
=
3
p1
.
start
()
p1
.
stop
()
self
.
assertEqual
(
squizz
.
squozz
,
3
)
def
test_patch_propogrates_exc_on_exit
(
self
):
class
holder
:
...
...
@@ -1696,7 +1696,12 @@ class PatchTest(unittest.TestCase):
def
test
(
mock
):
raise
RuntimeError
self
.
assertRaises
(
RuntimeError
,
test
)
with
uncache
(
'squizz'
):
squizz
=
Mock
()
sys
.
modules
[
'squizz'
]
=
squizz
self
.
assertRaises
(
RuntimeError
,
test
)
self
.
assertIs
(
holder
.
exc_info
[
0
],
RuntimeError
)
self
.
assertIsNotNone
(
holder
.
exc_info
[
1
],
'exception value not propgated'
)
...
...
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