mirror of https://github.com/django/django.git
Refs #23433 -- Fixed test_django_admin_py.DeprecationTest tests failures on Windows and Python < 3.8.
subprocess.run()'s args parameter accepts a path-like object on Windows since Python 3.8.
This commit is contained in:
parent
09341856ed
commit
3fb7c12158
|
@ -1,6 +1,6 @@
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import django
|
import django
|
||||||
from django.test import SimpleTestCase
|
from django.test import SimpleTestCase
|
||||||
|
@ -12,6 +12,10 @@ class DeprecationTests(SimpleTestCase):
|
||||||
b'django-admin.'
|
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):
|
def _run_test(self, args):
|
||||||
p = subprocess.run(
|
p = subprocess.run(
|
||||||
[sys.executable, *args],
|
[sys.executable, *args],
|
||||||
|
@ -22,8 +26,7 @@ class DeprecationTests(SimpleTestCase):
|
||||||
return p.stdout, p.stderr
|
return p.stdout, p.stderr
|
||||||
|
|
||||||
def test_django_admin_py_deprecated(self):
|
def test_django_admin_py_deprecated(self):
|
||||||
django_admin_py = Path(django.__file__).parent / 'bin' / 'django-admin.py'
|
_, err = self._run_test(['-Wd', self.django_admin_py, '--version'])
|
||||||
_, err = self._run_test(['-Wd', django_admin_py, '--version'])
|
|
||||||
self.assertIn(self.DEPRECATION_MESSAGE, err)
|
self.assertIn(self.DEPRECATION_MESSAGE, err)
|
||||||
|
|
||||||
def test_main_not_deprecated(self):
|
def test_main_not_deprecated(self):
|
||||||
|
@ -31,7 +34,6 @@ class DeprecationTests(SimpleTestCase):
|
||||||
self.assertNotIn(self.DEPRECATION_MESSAGE, err)
|
self.assertNotIn(self.DEPRECATION_MESSAGE, err)
|
||||||
|
|
||||||
def test_django_admin_py_equivalent_main(self):
|
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([self.django_admin_py, '--version'])
|
||||||
django_admin_py_out, _ = self._run_test([django_admin_py, '--version'])
|
|
||||||
django_out, _ = self._run_test(['-m', 'django', '--version'])
|
django_out, _ = self._run_test(['-m', 'django', '--version'])
|
||||||
self.assertEqual(django_admin_py_out, django_out)
|
self.assertEqual(django_admin_py_out, django_out)
|
||||||
|
|
Loading…
Reference in New Issue