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
b46c0ea6
Kaydet (Commit)
b46c0ea6
authored
Şub 13, 2016
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26190 -- Returned handle() result from call_command
Thanks Tim Graham for the review.
üst
47b5a6a4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
20 deletions
+25
-20
base.py
django/core/management/base.py
+6
-7
django-admin.txt
docs/ref/django-admin.txt
+8
-0
1.10.txt
docs/releases/1.10.txt
+3
-0
tests.py
tests/user_commands/tests.py
+8
-13
No files found.
django/core/management/base.py
Dosyayı görüntüle @
b46c0ea6
...
...
@@ -348,18 +348,17 @@ class BaseCommand(object):
output
=
self
.
handle
(
*
args
,
**
options
)
if
output
:
if
self
.
output_transaction
:
# This needs to be imported here, because it relies on
# settings.
from
django.db
import
connections
,
DEFAULT_DB_ALIAS
connection
=
connections
[
options
.
get
(
'database'
,
DEFAULT_DB_ALIAS
)]
if
connection
.
ops
.
start_transaction_sql
():
self
.
stdout
.
write
(
self
.
style
.
SQL_KEYWORD
(
connection
.
ops
.
start_transaction_sql
()))
output
=
'
%
s
\n
%
s
\n
%
s'
%
(
self
.
style
.
SQL_KEYWORD
(
connection
.
ops
.
start_transaction_sql
()),
output
,
self
.
style
.
SQL_KEYWORD
(
connection
.
ops
.
end_transaction_sql
()),
)
self
.
stdout
.
write
(
output
)
if
self
.
output_transaction
:
self
.
stdout
.
write
(
'
\n
'
+
self
.
style
.
SQL_KEYWORD
(
connection
.
ops
.
end_transaction_sql
()))
finally
:
if
saved_locale
is
not
None
:
translation
.
activate
(
saved_locale
)
return
output
def
check
(
self
,
app_configs
=
None
,
tags
=
None
,
display_num_errors
=
False
,
include_deployment_checks
=
False
,
fail_level
=
checks
.
ERROR
):
...
...
docs/ref/django-admin.txt
Dosyayı görüntüle @
b46c0ea6
...
...
@@ -1793,6 +1793,14 @@ Command options which take multiple options are passed a list::
management.call_command('dumpdata', exclude=['contenttypes', 'auth'])
The return value of the ``call_command()`` function is the same as the return
value of the ``handle()`` method of the command.
.. versionchanged:: 1.10
``call_command()`` now returns the value received from the
``command.handle()`` method.
Output redirection
==================
...
...
docs/releases/1.10.txt
Dosyayı görüntüle @
b46c0ea6
...
...
@@ -230,6 +230,9 @@ Internationalization
Management Commands
~~~~~~~~~~~~~~~~~~~
* :func:`~django.core.management.call_command` now returns the value returned
from the ``command.handle()`` method.
* The new :option:`check --fail-level` option allows specifying the message
level that will cause the command to exit with a non-zero status.
...
...
tests/user_commands/tests.py
Dosyayı görüntüle @
b46c0ea6
...
...
@@ -61,17 +61,15 @@ class CommandTests(SimpleTestCase):
def
test_deactivate_locale_set
(
self
):
# Deactivate translation when set to true
out
=
StringIO
()
with
translation
.
override
(
'pl'
):
management
.
call_command
(
'leave_locale_alone_false'
,
stdout
=
out
)
self
.
assert
Equal
(
out
.
getvalue
(),
""
)
result
=
management
.
call_command
(
'leave_locale_alone_false'
,
stdout
=
StringIO
()
)
self
.
assert
IsNone
(
result
)
def
test_configured_locale_preserved
(
self
):
# Leaves locale from settings when set to false
out
=
StringIO
()
with
translation
.
override
(
'pl'
):
management
.
call_command
(
'leave_locale_alone_true'
,
stdout
=
out
)
self
.
assertEqual
(
out
.
getvalue
(),
"pl
\n
"
)
result
=
management
.
call_command
(
'leave_locale_alone_true'
,
stdout
=
StringIO
()
)
self
.
assertEqual
(
result
,
"pl
"
)
def
test_find_command_without_PATH
(
self
):
"""
...
...
@@ -132,16 +130,13 @@ class CommandTests(SimpleTestCase):
self
.
assertIn
(
"Dave, my mind is going. I can feel it. I can feel it.
\n
"
,
out
.
getvalue
())
def
test_calling_a_command_with_no_app_labels_and_parameters_should_raise_a_command_error
(
self
):
out
=
StringIO
()
with
self
.
assertRaises
(
CommandError
):
management
.
call_command
(
'hal'
,
stdout
=
out
)
management
.
call_command
(
'hal'
,
stdout
=
StringIO
()
)
def
test_output_transaction
(
self
):
out
=
StringIO
()
management
.
call_command
(
'transaction'
,
stdout
=
out
,
no_color
=
True
)
output
=
out
.
getvalue
()
.
strip
()
self
.
assertTrue
(
output
.
startswith
(
connection
.
ops
.
start_transaction_sql
()))
self
.
assertTrue
(
output
.
endswith
(
connection
.
ops
.
end_transaction_sql
()))
output
=
management
.
call_command
(
'transaction'
,
stdout
=
StringIO
(),
no_color
=
True
)
self
.
assertTrue
(
output
.
strip
()
.
startswith
(
connection
.
ops
.
start_transaction_sql
()))
self
.
assertTrue
(
output
.
strip
()
.
endswith
(
connection
.
ops
.
end_transaction_sql
()))
def
test_call_command_no_checks
(
self
):
"""
...
...
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