forked from django/django
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #23433 -- Deprecated django-admin.py entry point in favor of dj…
…ango-admin. Unify on the entry point created by setuptools entry_points feature.
- Loading branch information
Showing
10 changed files
with
79 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
#!/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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import subprocess | ||
import sys | ||
from pathlib import Path | ||
|
||
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 _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): | ||
django_admin_py = Path(django.__file__).parent / 'bin' / 'django-admin.py' | ||
_, err = self._run_test(['-Wd', 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 = Path(django.__file__).parent / 'bin' / 'django-admin.py' | ||
django_admin_py_out, _ = self._run_test([django_admin_py, '--version']) | ||
django_out, _ = self._run_test(['-m', 'django', '--version']) | ||
self.assertEqual(django_admin_py_out, django_out) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters