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
f6989e55
Kaydet (Commit)
f6989e55
authored
Mar 27, 2013
tarafından
Jacob Kaplan-Moss
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge remote-tracking branch 'ptone/18985-fix'
üst
34a50e99
e79b857a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
22 deletions
+40
-22
__init__.py
django/conf/__init__.py
+10
-8
test.py
django/core/management/commands/test.py
+17
-0
simple.py
django/test/simple.py
+0
-13
runtests.py
tests/runtests.py
+9
-0
tests.py
tests/test_runner/deprecation_app/tests.py
+2
-0
tests.py
tests/test_runner/tests.py
+2
-1
No files found.
django/conf/__init__.py
Dosyayı görüntüle @
f6989e55
...
...
@@ -8,6 +8,7 @@ a list of all possible variables.
import
logging
import
os
import
sys
import
time
# Needed for Windows
import
warnings
...
...
@@ -57,14 +58,15 @@ class LazySettings(LazyObject):
"""
Setup logging from LOGGING_CONFIG and LOGGING settings.
"""
try
:
# Route warnings through python logging
logging
.
captureWarnings
(
True
)
# Allow DeprecationWarnings through the warnings filters
warnings
.
simplefilter
(
"default"
,
DeprecationWarning
)
except
AttributeError
:
# No captureWarnings on Python 2.6, DeprecationWarnings are on anyway
pass
if
not
sys
.
warnoptions
:
try
:
# Route warnings through python logging
logging
.
captureWarnings
(
True
)
# Allow DeprecationWarnings through the warnings filters
warnings
.
simplefilter
(
"default"
,
DeprecationWarning
)
except
AttributeError
:
# No captureWarnings on Python 2.6, DeprecationWarnings are on anyway
pass
if
self
.
LOGGING_CONFIG
:
from
django.utils.log
import
DEFAULT_LOGGING
...
...
django/core/management/commands/test.py
Dosyayı görüntüle @
f6989e55
import
logging
import
sys
import
os
from
optparse
import
make_option
,
OptionParser
...
...
@@ -6,6 +7,7 @@ from django.conf import settings
from
django.core.management.base
import
BaseCommand
from
django.test.utils
import
get_runner
class
Command
(
BaseCommand
):
option_list
=
BaseCommand
.
option_list
+
(
make_option
(
'--noinput'
,
...
...
@@ -57,6 +59,21 @@ class Command(BaseCommand):
version
=
self
.
get_version
(),
option_list
=
options
)
def
execute
(
self
,
*
args
,
**
options
):
if
int
(
options
[
'verbosity'
])
>
0
:
# ensure that deprecation warnings are displayed during testing
# the following state is assumed:
# logging.capturewarnings is true
# a "default" level warnings filter has been added for
# DeprecationWarning. See django.conf.LazySettings._configure_logging
logger
=
logging
.
getLogger
(
'py.warnings'
)
handler
=
logging
.
StreamHandler
()
logger
.
addHandler
(
handler
)
super
(
Command
,
self
)
.
execute
(
*
args
,
**
options
)
if
int
(
options
[
'verbosity'
])
>
0
:
# remove the testing-specific handler
logger
.
removeHandler
(
handler
)
def
handle
(
self
,
*
test_labels
,
**
options
):
from
django.conf
import
settings
from
django.test.utils
import
get_runner
...
...
django/test/simple.py
Dosyayı görüntüle @
f6989e55
import
logging
import
unittest
as
real_unittest
from
django.conf
import
settings
...
...
@@ -366,19 +365,7 @@ class DjangoTestSuiteRunner(object):
self
.
setup_test_environment
()
suite
=
self
.
build_suite
(
test_labels
,
extra_tests
)
old_config
=
self
.
setup_databases
()
if
self
.
verbosity
>
0
:
# ensure that deprecation warnings are displayed during testing
# the following state is assumed:
# logging.capturewarnings is true
# a "default" level warnings filter has been added for
# DeprecationWarning. See django.conf.LazySettings._configure_logging
logger
=
logging
.
getLogger
(
'py.warnings'
)
handler
=
logging
.
StreamHandler
()
logger
.
addHandler
(
handler
)
result
=
self
.
run_suite
(
suite
)
if
self
.
verbosity
>
0
:
# remove the testing-specific handler
logger
.
removeHandler
(
handler
)
self
.
teardown_databases
(
old_config
)
self
.
teardown_test_environment
()
return
self
.
suite_result
(
suite
,
result
)
tests/runtests.py
Dosyayı görüntüle @
f6989e55
#!/usr/bin/env python
import
logging
import
os
import
shutil
import
subprocess
...
...
@@ -82,6 +83,14 @@ def setup(verbosity, test_labels):
settings
.
LANGUAGE_CODE
=
'en'
settings
.
SITE_ID
=
1
if
verbosity
>
0
:
# Ensure any warnings captured to logging are piped through a verbose
# logging handler. If any -W options were passed explicitly on command
# line, warnings are not captured, and this has no effect.
logger
=
logging
.
getLogger
(
'py.warnings'
)
handler
=
logging
.
StreamHandler
()
logger
.
addHandler
(
handler
)
# Load all the ALWAYS_INSTALLED_APPS.
get_apps
()
...
...
tests/test_runner/deprecation_app/tests.py
Dosyayı görüntüle @
f6989e55
...
...
@@ -2,6 +2,8 @@ import warnings
from
django.test
import
TestCase
warnings
.
warn
(
"module-level warning from deprecation_app"
,
DeprecationWarning
)
class
DummyTest
(
TestCase
):
def
test_warn
(
self
):
warnings
.
warn
(
"warning from test"
,
DeprecationWarning
)
...
...
tests/test_runner/tests.py
Dosyayı görüntüle @
f6989e55
...
...
@@ -299,7 +299,8 @@ class DeprecationDisplayTest(AdminScriptTestCase):
def
test_runner_deprecation_verbosity_default
(
self
):
args
=
[
'test'
,
'--settings=test_project.settings'
]
out
,
err
=
self
.
run_django_admin
(
args
)
self
.
assertTrue
(
"DeprecationWarning: warning from test"
in
err
)
self
.
assertIn
(
"DeprecationWarning: warning from test"
,
err
)
self
.
assertIn
(
"DeprecationWarning: module-level warning from deprecation_app"
,
err
)
@unittest.skipIf
(
sys
.
version_info
[:
2
]
==
(
2
,
6
),
"On Python 2.6, DeprecationWarnings are visible anyway"
)
...
...
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