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
2b691404
Kaydet (Commit)
2b691404
authored
Ock 22, 2014
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #21849 -- Included the count of silenced system checks in output.
üst
3e4dc5ec
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
21 deletions
+58
-21
base.py
django/core/management/base.py
+11
-8
tests.py
tests/admin_scripts/tests.py
+4
-4
tests.py
tests/check_framework/tests.py
+42
-8
tests.py
tests/logging_tests/tests.py
+1
-1
No files found.
django/core/management/base.py
Dosyayı görüntüle @
2b691404
...
@@ -365,11 +365,12 @@ class BaseCommand(object):
...
@@ -365,11 +365,12 @@ class BaseCommand(object):
Raises CommandError for any serious message (error or critical errors).
Raises CommandError for any serious message (error or critical errors).
If there are only light messages (like warnings), they are printed to
If there are only light messages (like warnings), they are printed to
stderr and no exception is raised.
stderr and no exception is raised.
"""
"""
all_issues
=
checks
.
run_checks
(
app_configs
=
app_configs
,
tags
=
tags
)
all_issues
=
checks
.
run_checks
(
app_configs
=
app_configs
,
tags
=
tags
)
msg
=
""
msg
=
""
visible_issue_count
=
0
# excludes silenced warnings
if
all_issues
:
if
all_issues
:
debugs
=
[
e
for
e
in
all_issues
if
e
.
level
<
checks
.
INFO
and
not
e
.
is_silenced
()]
debugs
=
[
e
for
e
in
all_issues
if
e
.
level
<
checks
.
INFO
and
not
e
.
is_silenced
()]
infos
=
[
e
for
e
in
all_issues
if
checks
.
INFO
<=
e
.
level
<
checks
.
WARNING
and
not
e
.
is_silenced
()]
infos
=
[
e
for
e
in
all_issues
if
checks
.
INFO
<=
e
.
level
<
checks
.
WARNING
and
not
e
.
is_silenced
()]
...
@@ -386,6 +387,7 @@ class BaseCommand(object):
...
@@ -386,6 +387,7 @@ class BaseCommand(object):
for
issues
,
group_name
in
sorted_issues
:
for
issues
,
group_name
in
sorted_issues
:
if
issues
:
if
issues
:
visible_issue_count
+=
len
(
issues
)
formatted
=
(
formatted
=
(
color_style
()
.
ERROR
(
force_str
(
e
))
color_style
()
.
ERROR
(
force_str
(
e
))
if
e
.
is_serious
()
if
e
.
is_serious
()
...
@@ -393,21 +395,22 @@ class BaseCommand(object):
...
@@ -393,21 +395,22 @@ class BaseCommand(object):
for
e
in
issues
)
for
e
in
issues
)
formatted
=
"
\n
"
.
join
(
sorted
(
formatted
))
formatted
=
"
\n
"
.
join
(
sorted
(
formatted
))
msg
+=
'
\n
%
s:
\n
%
s
\n
'
%
(
group_name
,
formatted
)
msg
+=
'
\n
%
s:
\n
%
s
\n
'
%
(
group_name
,
formatted
)
if
msg
:
msg
=
"System check identified some issues:
\n
%
s"
%
msg
msg
=
"System check identified some issues:
\n
%
s"
%
msg
if
display_num_errors
:
if
display_num_errors
:
if
msg
:
if
msg
:
msg
+=
'
\n
'
msg
+=
'
\n
'
msg
+=
"System check identified
%
s."
%
(
msg
+=
"System check identified
%
s (
%
s silenced)."
%
(
"no issues"
if
len
(
all_issues
)
==
0
else
"no issues"
if
visible_issue_count
==
0
else
"1 issue"
if
len
(
all_issues
)
==
1
else
"1 issue"
if
visible_issue_count
==
1
else
"
%
s issues"
%
len
(
all_issues
)
"
%
s issues"
%
visible_issue_count
,
len
(
all_issues
)
-
visible_issue_count
,
)
)
if
any
(
e
.
is_serious
()
and
not
e
.
is_silenced
()
for
e
in
all_issues
):
if
any
(
e
.
is_serious
()
and
not
e
.
is_silenced
()
for
e
in
all_issues
):
raise
CommandError
(
msg
)
raise
CommandError
(
msg
)
elif
msg
and
all_issues
:
elif
msg
and
visible_issue_count
:
self
.
stderr
.
write
(
msg
)
self
.
stderr
.
write
(
msg
)
elif
msg
:
elif
msg
:
self
.
stdout
.
write
(
msg
)
self
.
stdout
.
write
(
msg
)
...
...
tests/admin_scripts/tests.py
Dosyayı görüntüle @
2b691404
...
@@ -1124,7 +1124,7 @@ class ManageCheck(AdminScriptTestCase):
...
@@ -1124,7 +1124,7 @@ class ManageCheck(AdminScriptTestCase):
args
=
[
'check'
]
args
=
[
'check'
]
out
,
err
=
self
.
run_manage
(
args
)
out
,
err
=
self
.
run_manage
(
args
)
self
.
assertNoOutput
(
err
)
self
.
assertNoOutput
(
err
)
self
.
assertEqual
(
out
,
'System check identified no issues.
\n
'
)
self
.
assertEqual
(
out
,
'System check identified no issues
(0 silenced)
.
\n
'
)
def
test_app_with_import
(
self
):
def
test_app_with_import
(
self
):
""" manage.py check does not raise errors when an app imports a base
""" manage.py check does not raise errors when an app imports a base
...
@@ -1139,7 +1139,7 @@ class ManageCheck(AdminScriptTestCase):
...
@@ -1139,7 +1139,7 @@ class ManageCheck(AdminScriptTestCase):
args
=
[
'check'
]
args
=
[
'check'
]
out
,
err
=
self
.
run_manage
(
args
)
out
,
err
=
self
.
run_manage
(
args
)
self
.
assertNoOutput
(
err
)
self
.
assertNoOutput
(
err
)
self
.
assertEqual
(
out
,
'System check identified no issues.
\n
'
)
self
.
assertEqual
(
out
,
'System check identified no issues
(0 silenced)
.
\n
'
)
def
test_output_format
(
self
):
def
test_output_format
(
self
):
""" All errors/warnings should be sorted by level and by message. """
""" All errors/warnings should be sorted by level and by message. """
...
@@ -1163,7 +1163,7 @@ class ManageCheck(AdminScriptTestCase):
...
@@ -1163,7 +1163,7 @@ class ManageCheck(AdminScriptTestCase):
"obj: First warning
\n
"
"obj: First warning
\n
"
"
\t
HINT: Hint
\n
"
"
\t
HINT: Hint
\n
"
"
\n
"
"
\n
"
"System check identified 3 issues.
\n
"
"System check identified 3 issues
(0 silenced)
.
\n
"
)
)
self
.
assertEqual
(
err
,
expected_err
)
self
.
assertEqual
(
err
,
expected_err
)
self
.
assertNoOutput
(
out
)
self
.
assertNoOutput
(
out
)
...
@@ -1191,7 +1191,7 @@ class ManageCheck(AdminScriptTestCase):
...
@@ -1191,7 +1191,7 @@ class ManageCheck(AdminScriptTestCase):
"WARNINGS:
\n
"
"WARNINGS:
\n
"
"?: A warning
\n
"
"?: A warning
\n
"
"
\n
"
"
\n
"
"System check identified 1 issue.
\n
"
"System check identified 1 issue
(0 silenced)
.
\n
"
)
)
self
.
assertEqual
(
err
,
expected_err
)
self
.
assertEqual
(
err
,
expected_err
)
self
.
assertNoOutput
(
out
)
self
.
assertNoOutput
(
out
)
...
...
tests/check_framework/tests.py
Dosyayı görüntüle @
2b691404
...
@@ -7,7 +7,7 @@ import sys
...
@@ -7,7 +7,7 @@ import sys
from
django.apps
import
apps
from
django.apps
import
apps
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core
import
checks
from
django.core
import
checks
from
django.core.checks
import
Error
from
django.core.checks
import
Error
,
Warning
from
django.core.checks.registry
import
CheckRegistry
from
django.core.checks.registry
import
CheckRegistry
from
django.core.checks.compatibility.django_1_6_0
import
check_1_6_compatibility
from
django.core.checks.compatibility.django_1_6_0
import
check_1_6_compatibility
from
django.core.management.base
import
CommandError
from
django.core.management.base
import
CommandError
...
@@ -195,12 +195,22 @@ class CheckCommandTests(TestCase):
...
@@ -195,12 +195,22 @@ class CheckCommandTests(TestCase):
self
.
assertRaises
(
CommandError
,
call_command
,
'check'
,
tags
=
[
'missingtag'
])
self
.
assertRaises
(
CommandError
,
call_command
,
'check'
,
tags
=
[
'missingtag'
])
def
custom_system_check
(
app_configs
,
**
kwargs
):
def
custom_
error_
system_check
(
app_configs
,
**
kwargs
):
return
[
return
[
Error
(
Error
(
'Error'
,
'Error'
,
hint
=
None
,
hint
=
None
,
id
=
'mycheck.E001'
,
id
=
'myerrorcheck.E001'
,
)
]
def
custom_warning_system_check
(
app_configs
,
**
kwargs
):
return
[
Warning
(
'Warning'
,
hint
=
None
,
id
=
'mywarningcheck.E001'
,
)
)
]
]
...
@@ -209,15 +219,39 @@ class SilencingCheckTests(TestCase):
...
@@ -209,15 +219,39 @@ class SilencingCheckTests(TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
old_stdout
,
self
.
old_stderr
=
sys
.
stdout
,
sys
.
stderr
self
.
old_stdout
,
self
.
old_stderr
=
sys
.
stdout
,
sys
.
stderr
sys
.
stdout
,
sys
.
stderr
=
StringIO
(),
StringIO
()
self
.
stdout
,
self
.
stderr
=
StringIO
(),
StringIO
()
sys
.
stdout
,
sys
.
stderr
=
self
.
stdout
,
self
.
stderr
def
tearDown
(
self
):
def
tearDown
(
self
):
sys
.
stdout
,
sys
.
stderr
=
self
.
old_stdout
,
self
.
old_stderr
sys
.
stdout
,
sys
.
stderr
=
self
.
old_stdout
,
self
.
old_stderr
@override_settings
(
SILENCED_SYSTEM_CHECKS
=
[
'mycheck.E001'
])
@override_settings
(
SILENCED_SYSTEM_CHECKS
=
[
'myerrorcheck.E001'
])
@override_system_checks
([
custom_system_check
])
@override_system_checks
([
custom_error_system_check
])
def
test_simple
(
self
):
def
test_silenced_error
(
self
):
out
=
StringIO
()
err
=
StringIO
()
try
:
try
:
call_command
(
'check'
)
call_command
(
'check'
,
stdout
=
out
,
stderr
=
err
)
except
CommandError
:
except
CommandError
:
self
.
fail
(
"The mycheck.E001 check should be silenced."
)
self
.
fail
(
"The mycheck.E001 check should be silenced."
)
self
.
assertEqual
(
out
.
getvalue
(),
''
)
self
.
assertEqual
(
err
.
getvalue
(),
'System check identified some issues:
\n\n
'
'ERRORS:
\n
'
'?: (myerrorcheck.E001) Error
\n\n
'
'System check identified 1 issue (0 silenced).
\n
'
)
@override_settings
(
SILENCED_SYSTEM_CHECKS
=
[
'mywarningcheck.E001'
])
@override_system_checks
([
custom_warning_system_check
])
def
test_silenced_warning
(
self
):
out
=
StringIO
()
err
=
StringIO
()
try
:
call_command
(
'check'
,
stdout
=
out
,
stderr
=
err
)
except
CommandError
:
self
.
fail
(
"The mycheck.E001 check should be silenced."
)
self
.
assertEqual
(
out
.
getvalue
(),
'System check identified no issues (1 silenced).
\n
'
)
self
.
assertEqual
(
err
.
getvalue
(),
''
)
tests/logging_tests/tests.py
Dosyayı görüntüle @
2b691404
...
@@ -333,7 +333,7 @@ class SettingsConfigTest(AdminScriptTestCase):
...
@@ -333,7 +333,7 @@ class SettingsConfigTest(AdminScriptTestCase):
# validate is just an example command to trigger settings configuration
# validate is just an example command to trigger settings configuration
out
,
err
=
self
.
run_manage
([
'validate'
])
out
,
err
=
self
.
run_manage
([
'validate'
])
self
.
assertNoOutput
(
err
)
self
.
assertNoOutput
(
err
)
self
.
assertOutput
(
out
,
"System check identified no issues."
)
self
.
assertOutput
(
out
,
"System check identified no issues
(0 silenced)
."
)
def
dictConfig
(
config
):
def
dictConfig
(
config
):
...
...
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