1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Refs #23433 -- Removed script argument from AdminScriptTestCase.run_test().

This commit is contained in:
Jon Dufresne 2019-11-13 06:30:40 -08:00 committed by Mariusz Felisiak
parent 8aefe11137
commit 8eb0f73eed

View File

@ -93,7 +93,7 @@ class AdminScriptTestCase(SimpleTestCase):
paths.append(os.path.dirname(backend_dir)) paths.append(os.path.dirname(backend_dir))
return paths return paths
def run_test(self, script, args, settings_file=None, apps=None): def run_test(self, args, settings_file=None, apps=None):
base_dir = os.path.dirname(self.test_dir) base_dir = os.path.dirname(self.test_dir)
# The base dir for Django's tests is one level up. # The base dir for Django's tests is one level up.
tests_dir = os.path.dirname(os.path.dirname(__file__)) tests_dir = os.path.dirname(os.path.dirname(__file__))
@ -117,7 +117,7 @@ class AdminScriptTestCase(SimpleTestCase):
test_environ['PYTHONWARNINGS'] = '' test_environ['PYTHONWARNINGS'] = ''
p = subprocess.run( p = subprocess.run(
[sys.executable, script] + args, [sys.executable, *args],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
cwd=self.test_dir, cwd=self.test_dir,
env=test_environ, universal_newlines=True, env=test_environ, universal_newlines=True,
@ -126,7 +126,7 @@ class AdminScriptTestCase(SimpleTestCase):
def run_django_admin(self, args, settings_file=None): def run_django_admin(self, args, settings_file=None):
script_dir = os.path.abspath(os.path.join(os.path.dirname(django.__file__), 'bin')) script_dir = os.path.abspath(os.path.join(os.path.dirname(django.__file__), 'bin'))
return self.run_test(os.path.join(script_dir, 'django-admin.py'), args, settings_file) return self.run_test([os.path.join(script_dir, 'django-admin.py'), *args], settings_file)
def run_manage(self, args, settings_file=None, manage_py=None): def run_manage(self, args, settings_file=None, manage_py=None):
template_manage_py = ( template_manage_py = (
@ -144,7 +144,7 @@ class AdminScriptTestCase(SimpleTestCase):
with open(test_manage_py, 'w') as fp: with open(test_manage_py, 'w') as fp:
fp.write(manage_py_contents) fp.write(manage_py_contents)
return self.run_test('./manage.py', args, settings_file) return self.run_test(['./manage.py', *args], settings_file)
def assertNoOutput(self, stream): def assertNoOutput(self, stream):
"Utility assertion: assert that the given stream is empty" "Utility assertion: assert that the given stream is empty"
@ -2263,11 +2263,11 @@ class MainModule(AdminScriptTestCase):
def test_runs_django_admin(self): def test_runs_django_admin(self):
cmd_out, _ = self.run_django_admin(['--version']) cmd_out, _ = self.run_django_admin(['--version'])
mod_out, _ = self.run_test('-m', ['django', '--version']) mod_out, _ = self.run_test(['-m', 'django', '--version'])
self.assertEqual(mod_out, cmd_out) self.assertEqual(mod_out, cmd_out)
def test_program_name_in_help(self): def test_program_name_in_help(self):
out, err = self.run_test('-m', ['django', 'help']) out, err = self.run_test(['-m', 'django', 'help'])
self.assertOutput(out, "Type 'python -m django help <subcommand>' for help on a specific subcommand.") self.assertOutput(out, "Type 'python -m django help <subcommand>' for help on a specific subcommand.")