Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
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
django
Commits
7f9fd42b
Kaydet (Commit)
7f9fd42b
authored
Agu 08, 2016
tarafından
Chris Jerdonek
Kaydeden (comit)
Tim Graham
Agu 10, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27019 -- Made teardown_test_environment() restore the old DEBUG.
üst
a757c681
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
6 deletions
+24
-6
runner.py
django/test/runner.py
+1
-3
utils.py
django/test/utils.py
+15
-2
advanced.txt
docs/topics/testing/advanced.txt
+8
-1
No files found.
django/test/runner.py
Dosyayı görüntüle @
7f9fd42b
...
...
@@ -9,7 +9,6 @@ import textwrap
import
unittest
from
importlib
import
import_module
from
django.conf
import
settings
from
django.core.exceptions
import
ImproperlyConfigured
from
django.db
import
DEFAULT_DB_ALIAS
,
connections
from
django.test
import
SimpleTestCase
,
TestCase
...
...
@@ -413,8 +412,7 @@ class DiscoverRunner(object):
)
def
setup_test_environment
(
self
,
**
kwargs
):
setup_test_environment
()
settings
.
DEBUG
=
self
.
debug_mode
setup_test_environment
(
debug
=
self
.
debug_mode
)
unittest
.
installHandler
()
def
build_suite
(
self
,
test_labels
=
None
,
extra_tests
=
None
,
**
kwargs
):
...
...
django/test/utils.py
Dosyayı görüntüle @
7f9fd42b
...
...
@@ -94,18 +94,28 @@ def instrumented_test_render(self, context):
return
self
.
nodelist
.
render
(
context
)
def
setup_test_environment
():
class
_SavedSettings
(
object
):
pass
def
setup_test_environment
(
debug
=
None
):
"""
Perform global pre-test setup, such as installing the instrumented template
renderer and setting the email backend to the locmem email backend.
"""
if
hasattr
(
Template
,
'_original_render
'
):
if
hasattr
(
_SavedSettings
,
'debug
'
):
# Executing this function twice would overwrite the saved values.
raise
RuntimeError
(
"setup_test_environment() was already called and can't be called "
"again without first calling teardown_test_environment()."
)
if
debug
is
None
:
debug
=
settings
.
DEBUG
_SavedSettings
.
debug
=
settings
.
DEBUG
settings
.
DEBUG
=
debug
Template
.
_original_render
=
Template
.
_render
Template
.
_render
=
instrumented_test_render
...
...
@@ -129,6 +139,9 @@ def teardown_test_environment():
Perform any global post-test teardown, such as restoring the original
template renderer and restoring the email sending functions.
"""
settings
.
DEBUG
=
_SavedSettings
.
debug
del
_SavedSettings
.
debug
Template
.
_render
=
Template
.
_original_render
del
Template
.
_original_render
...
...
docs/topics/testing/advanced.txt
Dosyayı görüntüle @
7f9fd42b
...
...
@@ -612,11 +612,18 @@ Testing utilities
To assist in the creation of your own test runner, Django provides a number of
utility methods in the ``django.test.utils`` module.
.. function:: setup_test_environment()
.. function:: setup_test_environment(
debug=None
)
Performs global pre-test setup, such as installing instrumentation for the
template rendering system and setting up the dummy email outbox.
If ``debug`` isn't ``None``, the :setting:`DEBUG` setting is updated to its
value.
.. versionchanged:: 1.11
The ``debug`` argument was added.
.. function:: teardown_test_environment()
Performs global post-test teardown, such as removing instrumentation from
...
...
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