From 97f377cd3520794f7d4e97b7aa1fa2093c426273 Mon Sep 17 00:00:00 2001 From: Jan Szoja Date: Tue, 31 Aug 2021 09:42:08 +0200 Subject: [PATCH] Refs #25264 -- Added test for command --help output with default options and custom arguments. --- tests/admin_scripts/tests.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index e754989101..e5216e93e9 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -1496,6 +1496,31 @@ class CommandTypes(AdminScriptTestCase): self.assertLess(tag_location, version_location) self.assertOutput(out, "Checks the entire Django project for potential problems.") + def test_help_default_options_with_custom_arguments(self): + args = ['base_command', '--help'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + expected_options = [ + '-h', + '--option_a OPTION_A', + '--option_b OPTION_B', + '--option_c OPTION_C', + '--version', + '-v {0,1,2,3}', + '--settings SETTINGS', + '--pythonpath PYTHONPATH', + '--traceback', + '--no-color', + '--force-color', + 'args ...', + ] + for option in expected_options: + self.assertOutput(out, f'[{option}]') + self.assertOutput(out, '--option_a OPTION_A, -a OPTION_A') + self.assertOutput(out, '--option_b OPTION_B, -b OPTION_B') + self.assertOutput(out, '--option_c OPTION_C, -c OPTION_C') + self.assertOutput(out, '-v {0,1,2,3}, --verbosity {0,1,2,3}') + def test_color_style(self): style = color.no_style() self.assertEqual(style.ERROR('Hello, world!'), 'Hello, world!')