From 175e6d77df526dea1ade94661e487072e7c7cd88 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Tue, 7 Feb 2012 18:46:29 +0000 Subject: Fixed #11745 -- Grouped commands by application in the output of `manage.py help`. Made 'version' consistent with 'help' while I was in the area, and added tests. Thanks Jannis for the feedback and review. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17462 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/admin_scripts/tests.py | 44 ++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 9 deletions(-) (limited to 'tests/regressiontests/admin_scripts/tests.py') diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py index e981f54c23..dd7e4b3d15 100644 --- a/tests/regressiontests/admin_scripts/tests.py +++ b/tests/regressiontests/admin_scripts/tests.py @@ -173,6 +173,10 @@ class AdminScriptTestCase(unittest.TestCase): "Utility assertion: assert that the given message exists in the output" self.assertTrue(msg in stream, "'%s' does not match actual output text '%s'" % (msg, stream)) + def assertNotInOutput(self, stream, msg): + "Utility assertion: assert that the given message doesn't exist in the output" + self.assertFalse(msg in stream, "'%s' matches actual output text '%s'" % (msg, stream)) + ########################################################################## # DJANGO ADMIN TESTS # This first series of test classes checks the environment processing @@ -1173,25 +1177,47 @@ class CommandTypes(AdminScriptTestCase): self.remove_settings('settings.py') def test_version(self): - "--version is handled as a special case" - args = ['--version'] + "version is handled as a special case" + args = ['version'] out, err = self.run_manage(args) self.assertNoOutput(err) self.assertOutput(out, get_version()) + def test_version_alternative(self): + "--version is equivalent to version" + args1, args2 = ['version'], ['--version'] + self.assertEqual(self.run_manage(args1), self.run_manage(args2)) + def test_help(self): - "--help is handled as a special case" - args = ['--help'] + "help is handled as a special case" + args = ['help'] out, err = self.run_manage(args) self.assertOutput(out, "Usage: manage.py subcommand [options] [args]") self.assertOutput(out, "Type 'manage.py help ' for help on a specific subcommand.") + self.assertOutput(out, '[django]') + self.assertOutput(out, 'startapp') + self.assertOutput(out, 'startproject') - def test_short_help(self): - "-h is handled as a short form of --help" - args = ['-h'] + def test_help_commands(self): + "help --commands shows the list of all available commands" + args = ['help', '--commands'] out, err = self.run_manage(args) - self.assertOutput(out, "Usage: manage.py subcommand [options] [args]") - self.assertOutput(out, "Type 'manage.py help ' for help on a specific subcommand.") + self.assertNotInOutput(out, 'Usage:') + self.assertNotInOutput(out, 'Options:') + self.assertNotInOutput(out, '[django]') + self.assertOutput(out, 'startapp') + self.assertOutput(out, 'startproject') + self.assertNotInOutput(out, '\n\n') + + def test_help_alternative(self): + "--help is equivalent to help" + args1, args2 = ['help'], ['--help'] + self.assertEqual(self.run_manage(args1), self.run_manage(args2)) + + def test_help_short_altert(self): + "-h is handled as a short form of --help" + args1, args2 = ['--help'], ['-h'] + self.assertEqual(self.run_manage(args1), self.run_manage(args2)) def test_specific_help(self): "--help can be used on a specific command" -- cgit v1.3