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
33ac036a
Kaydet (Commit)
33ac036a
authored
Şub 21, 2018
tarafından
Tom Forbes
Kaydeden (comit)
Tim Graham
Şub 21, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28398 -- Added suggestions for mistyped management commands.
üst
f7b46f0b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
4 deletions
+26
-4
__init__.py
django/core/management/__init__.py
+6
-4
tests.py
tests/admin_scripts/tests.py
+20
-0
No files found.
django/core/management/__init__.py
Dosyayı görüntüle @
33ac036a
...
...
@@ -3,6 +3,7 @@ import os
import
pkgutil
import
sys
from
collections
import
OrderedDict
,
defaultdict
from
difflib
import
get_close_matches
from
importlib
import
import_module
import
django
...
...
@@ -203,10 +204,11 @@ class ManagementUtility:
settings
.
INSTALLED_APPS
else
:
sys
.
stderr
.
write
(
"No Django settings specified.
\n
"
)
sys
.
stderr
.
write
(
"Unknown command:
%
r
\n
Type '
%
s help' for usage.
\n
"
%
(
subcommand
,
self
.
prog_name
)
)
possible_matches
=
get_close_matches
(
subcommand
,
commands
)
sys
.
stderr
.
write
(
'Unknown command:
%
r'
%
subcommand
)
if
possible_matches
:
sys
.
stderr
.
write
(
'. Did you mean
%
s?'
%
possible_matches
[
0
])
sys
.
stderr
.
write
(
"
\n
Type '
%
s help' for usage.
\n
"
%
self
.
prog_name
)
sys
.
exit
(
1
)
if
isinstance
(
app_name
,
BaseCommand
):
# If the command is already loaded, use it directly.
...
...
tests/admin_scripts/tests.py
Dosyayı görüntüle @
33ac036a
...
...
@@ -2256,3 +2256,23 @@ class MainModule(AdminScriptTestCase):
def
test_program_name_in_help
(
self
):
out
,
err
=
self
.
run_test
(
'-m'
,
[
'django'
,
'help'
])
self
.
assertOutput
(
out
,
"Type 'python -m django help <subcommand>' for help on a specific subcommand."
)
class
DjangoAdminSuggestions
(
AdminScriptTestCase
):
def
setUp
(
self
):
self
.
write_settings
(
'settings.py'
)
def
tearDown
(
self
):
self
.
remove_settings
(
'settings.py'
)
def
test_suggestions
(
self
):
args
=
[
'rnserver'
,
'--settings=test_project.settings'
]
out
,
err
=
self
.
run_django_admin
(
args
)
self
.
assertNoOutput
(
out
)
self
.
assertOutput
(
err
,
"Unknown command: 'rnserver'. Did you mean runserver?"
)
def
test_no_suggestions
(
self
):
args
=
[
'abcdef'
,
'--settings=test_project.settings'
]
out
,
err
=
self
.
run_django_admin
(
args
)
self
.
assertNoOutput
(
out
)
self
.
assertNotInOutput
(
err
,
'Did you mean'
)
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