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
5949c211
Kaydet (Commit)
5949c211
authored
Haz 14, 2014
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Restored command error behavior when called from command line
Refs #19973.
üst
2ca5fc55
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
base.py
django/core/management/base.py
+7
-2
tests.py
tests/admin_scripts/tests.py
+4
-3
No files found.
django/core/management/base.py
Dosyayı görüntüle @
5949c211
...
...
@@ -52,11 +52,14 @@ class CommandParser(ArgumentParser):
# Catch missing argument for a better error message
if
(
hasattr
(
self
.
cmd
,
'missing_args_message'
)
and
not
(
args
or
any
([
not
arg
.
startswith
(
'-'
)
for
arg
in
args
]))):
raise
CommandError
(
"Error:
%
s"
%
self
.
cmd
.
missing_args_message
)
self
.
error
(
self
.
cmd
.
missing_args_message
)
return
super
(
CommandParser
,
self
)
.
parse_args
(
args
,
namespace
)
def
error
(
self
,
message
):
raise
CommandError
(
"Error:
%
s"
%
message
)
if
self
.
cmd
.
_called_from_command_line
:
super
(
CommandParser
,
self
)
.
error
(
message
)
else
:
raise
CommandError
(
"Error:
%
s"
%
message
)
def
handle_default_options
(
options
):
...
...
@@ -208,6 +211,7 @@ class BaseCommand(object):
args
=
''
# Configuration shortcuts that alter various logic.
_called_from_command_line
=
False
can_import_settings
=
True
output_transaction
=
False
# Whether to wrap the output in a "BEGIN; COMMIT;"
leave_locale_alone
=
False
...
...
@@ -338,6 +342,7 @@ class BaseCommand(object):
to stderr. If the ``--traceback`` option is present or the raised
``Exception`` is not ``CommandError``, raise it.
"""
self
.
_called_from_command_line
=
True
parser
=
self
.
create_parser
(
argv
[
0
],
argv
[
1
])
if
self
.
use_argparse
:
...
...
tests/admin_scripts/tests.py
Dosyayı görüntüle @
5949c211
...
...
@@ -1494,7 +1494,7 @@ class CommandTypes(AdminScriptTestCase):
"NoArg Commands raise an error if an argument is provided"
args
=
[
'noargs_command'
,
'argument'
]
out
,
err
=
self
.
run_manage
(
args
)
self
.
assertOutput
(
err
,
"
E
rror: unrecognized arguments: argument"
)
self
.
assertOutput
(
err
,
"
e
rror: unrecognized arguments: argument"
)
def
test_app_command
(
self
):
"User AppCommands can execute when a single app name is provided"
...
...
@@ -1508,7 +1508,7 @@ class CommandTypes(AdminScriptTestCase):
"User AppCommands raise an error when no app name is provided"
args
=
[
'app_command'
]
out
,
err
=
self
.
run_manage
(
args
)
self
.
assertOutput
(
err
,
'
E
rror: Enter at least one application label.'
)
self
.
assertOutput
(
err
,
'
e
rror: Enter at least one application label.'
)
def
test_app_command_multiple_apps
(
self
):
"User AppCommands raise an error when multiple app names are provided"
...
...
@@ -1642,9 +1642,10 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
]
def
test_wrong_args
(
self
):
"Make sure passing the wrong kinds of arguments
raises a CommandError
"
"Make sure passing the wrong kinds of arguments
outputs an error and prints usage
"
out
,
err
=
self
.
run_django_admin
([
'startproject'
])
self
.
assertNoOutput
(
out
)
self
.
assertOutput
(
err
,
"usage:"
)
self
.
assertOutput
(
err
,
"You must provide a project name."
)
def
test_simple_project
(
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