0
0
mirror of https://github.com/django/django.git synced 2024-11-21 10:59:04 +01:00

Refs #23433 -- Removed django-admin.py entry point per deprecation timeline.

This commit is contained in:
Mariusz Felisiak 2021-01-09 20:31:27 +01:00
parent 68e3ca13d7
commit 90c59b4e12
6 changed files with 18 additions and 74 deletions

View File

@ -1,21 +0,0 @@
#!/usr/bin/env python
# When the django-admin.py deprecation ends, remove this script.
import warnings
from django.core import management
try:
from django.utils.deprecation import RemovedInDjango40Warning
except ImportError:
raise ImportError(
'django-admin.py was deprecated in Django 3.1 and removed in Django '
'4.0. Please manually remove this script from your virtual environment '
'and use django-admin instead.'
)
if __name__ == "__main__":
warnings.warn(
'django-admin.py is deprecated in favor of django-admin.',
RemovedInDjango40Warning,
)
management.execute_from_command_line()

View File

@ -273,3 +273,5 @@ to remove usage of these features.
right-hand side.
* The ``django.db.models.query_utils.InvalidQuery`` exception class is removed.
* The ``django-admin.py`` entry point is removed.

View File

@ -36,8 +36,7 @@ _django_completion()
COMP_CWORD=$COMP_CWORD \
DJANGO_AUTO_COMPLETE=1 $1 ) )
}
# When the django-admin.py deprecation ends, remove django-admin.py.
complete -F _django_completion -o default django-admin.py manage.py django-admin
complete -F _django_completion -o default manage.py django-admin
_python_django_completion()
{
@ -45,7 +44,7 @@ _python_django_completion()
local PYTHON_EXE=${COMP_WORDS[0]##*/}
if echo "$PYTHON_EXE" | grep -qE "python([3-9]\.[0-9])?"; then
local PYTHON_SCRIPT=${COMP_WORDS[1]##*/}
if echo "$PYTHON_SCRIPT" | grep -qE "manage\.py|django-admin(\.py)?"; then
if echo "$PYTHON_SCRIPT" | grep -qE "manage\.py|django-admin"; then
COMPREPLY=( $( COMP_WORDS=( "${COMP_WORDS[*]:1}" )
COMP_CWORD=$(( COMP_CWORD-1 ))
DJANGO_AUTO_COMPLETE=1 ${COMP_WORDS[*]} ) )

View File

@ -36,8 +36,6 @@ project_urls =
[options]
python_requires = >=3.6
packages = find:
# When the django-admin.py deprecation ends, remove "scripts".
scripts = django/bin/django-admin.py
include_package_data = true
zip_safe = false
install_requires =

View File

@ -1,39 +0,0 @@
import os
import subprocess
import sys
import django
from django.test import SimpleTestCase
class DeprecationTests(SimpleTestCase):
DEPRECATION_MESSAGE = (
b'RemovedInDjango40Warning: django-admin.py is deprecated in favor of '
b'django-admin.'
)
def setUp(self):
script_dir = os.path.abspath(os.path.join(os.path.dirname(django.__file__), 'bin'))
self.django_admin_py = os.path.join(script_dir, 'django-admin.py')
def _run_test(self, args):
p = subprocess.run(
[sys.executable, *args],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=True,
)
return p.stdout, p.stderr
def test_django_admin_py_deprecated(self):
_, err = self._run_test(['-Wd', self.django_admin_py, '--version'])
self.assertIn(self.DEPRECATION_MESSAGE, err)
def test_main_not_deprecated(self):
_, err = self._run_test(['-Wd', '-m', 'django', '--version'])
self.assertNotIn(self.DEPRECATION_MESSAGE, err)
def test_django_admin_py_equivalent_main(self):
django_admin_py_out, _ = self._run_test([self.django_admin_py, '--version'])
django_out, _ = self._run_test(['-m', 'django', '--version'])
self.assertEqual(django_admin_py_out, django_out)

View File

@ -167,12 +167,12 @@ class AdminScriptTestCase(SimpleTestCase):
##########################################################################
# DJANGO ADMIN TESTS
# This first series of test classes checks the environment processing
# of the django-admin.py script
# of the django-admin.
##########################################################################
class DjangoAdminNoSettings(AdminScriptTestCase):
"A series of tests for django-admin.py when there is no settings.py file."
"A series of tests for django-admin when there is no settings.py file."
def test_builtin_command(self):
"no settings: django-admin builtin commands fail with an error when no settings provided"
@ -207,7 +207,8 @@ class DjangoAdminNoSettings(AdminScriptTestCase):
class DjangoAdminDefaultSettings(AdminScriptTestCase):
"""A series of tests for django-admin.py when using a settings.py file that
"""
A series of tests for django-admin when using a settings.py file that
contains the test application.
"""
def setUp(self):
@ -273,7 +274,8 @@ class DjangoAdminDefaultSettings(AdminScriptTestCase):
class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase):
"""A series of tests for django-admin.py when using a settings.py file that
"""
A series of tests for django-admin when using a settings.py file that
contains the test application specified using a full path.
"""
def setUp(self):
@ -340,7 +342,8 @@ class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase):
class DjangoAdminMinimalSettings(AdminScriptTestCase):
"""A series of tests for django-admin.py when using a settings.py file that
"""
A series of tests for django-admin when using a settings.py file that
doesn't contain the test application.
"""
def setUp(self):
@ -406,8 +409,9 @@ class DjangoAdminMinimalSettings(AdminScriptTestCase):
class DjangoAdminAlternateSettings(AdminScriptTestCase):
"""A series of tests for django-admin.py when using a settings file
with a name other than 'settings.py'.
"""
A series of tests for django-admin when using a settings file with a name
other than 'settings.py'.
"""
def setUp(self):
super().setUp()
@ -472,7 +476,8 @@ class DjangoAdminAlternateSettings(AdminScriptTestCase):
class DjangoAdminMultipleSettings(AdminScriptTestCase):
"""A series of tests for django-admin.py when multiple settings files
"""
A series of tests for django-admin when multiple settings files
(including the default 'settings.py') are available. The default settings
file is insufficient for performing the operations described, so the
alternate settings must be used by the running script.
@ -541,7 +546,7 @@ class DjangoAdminMultipleSettings(AdminScriptTestCase):
class DjangoAdminSettingsDirectory(AdminScriptTestCase):
"""
A series of tests for django-admin.py when the settings file is in a
A series of tests for django-admin when the settings file is in a
directory. (see #9751).
"""