summaryrefslogtreecommitdiff
path: root/tests/admin_scripts/test_django_admin_py.py
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2019-11-01 21:08:23 -0700
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-12-06 12:11:44 +0100
commit5708327c3769262b845730996ca2784245ada4d1 (patch)
tree131808ba694efd6c52ed6e0bf3c941267c6fa301 /tests/admin_scripts/test_django_admin_py.py
parent8eb0f73eed4535a9e53ffd988242b7294d859a55 (diff)
Fixed #23433 -- Deprecated django-admin.py entry point in favor of django-admin.
Unify on the entry point created by setuptools entry_points feature.
Diffstat (limited to 'tests/admin_scripts/test_django_admin_py.py')
-rw-r--r--tests/admin_scripts/test_django_admin_py.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/admin_scripts/test_django_admin_py.py b/tests/admin_scripts/test_django_admin_py.py
new file mode 100644
index 0000000000..56f5f0c1b5
--- /dev/null
+++ b/tests/admin_scripts/test_django_admin_py.py
@@ -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)