diff options
Diffstat (limited to 'tests/user_commands/management/commands')
16 files changed, 67 insertions, 64 deletions
diff --git a/tests/user_commands/management/commands/common_args.py b/tests/user_commands/management/commands/common_args.py index d7b288a267..ffc895b9fa 100644 --- a/tests/user_commands/management/commands/common_args.py +++ b/tests/user_commands/management/commands/common_args.py @@ -6,11 +6,11 @@ from django.core.management.base import BaseCommand, CommandError class Command(BaseCommand): def add_arguments(self, parser): try: - parser.add_argument('--version', action='version', version='A.B.C') + parser.add_argument("--version", action="version", version="A.B.C") except ArgumentError: pass else: - raise CommandError('--version argument does no yet exist') + raise CommandError("--version argument does no yet exist") def handle(self, *args, **options): - return 'Detected that --version already exists' + return "Detected that --version already exists" diff --git a/tests/user_commands/management/commands/dance.py b/tests/user_commands/management/commands/dance.py index efa1bc0d8a..2bb8c11309 100644 --- a/tests/user_commands/management/commands/dance.py +++ b/tests/user_commands/management/commands/dance.py @@ -3,21 +3,23 @@ from django.core.management.base import BaseCommand, CommandError class Command(BaseCommand): help = "Dance around like a madman." - args = '' - requires_system_checks = '__all__' + args = "" + requires_system_checks = "__all__" def add_arguments(self, parser): - parser.add_argument("integer", nargs='?', type=int, default=0) + parser.add_argument("integer", nargs="?", type=int, default=0) parser.add_argument("-s", "--style", default="Rock'n'Roll") parser.add_argument("-x", "--example") - parser.add_argument("--opt-3", action='store_true', dest='option3') + parser.add_argument("--opt-3", action="store_true", dest="option3") def handle(self, *args, **options): example = options["example"] if example == "raise": raise CommandError(returncode=3) - if options['verbosity'] > 0: + if options["verbosity"] > 0: self.stdout.write("I don't feel like dancing %s." % options["style"]) - self.stdout.write(','.join(options)) - if options['integer'] > 0: - self.stdout.write("You passed %d as a positional argument." % options['integer']) + self.stdout.write(",".join(options)) + if options["integer"] > 0: + self.stdout.write( + "You passed %d as a positional argument." % options["integer"] + ) diff --git a/tests/user_commands/management/commands/hal.py b/tests/user_commands/management/commands/hal.py index 5791e5fae0..6b9588b053 100644 --- a/tests/user_commands/management/commands/hal.py +++ b/tests/user_commands/management/commands/hal.py @@ -5,13 +5,18 @@ class Command(BaseCommand): help = "Useless command." def add_arguments(self, parser): - parser.add_argument('args', metavar='app_label', nargs='*', help='Specify the app label(s) to works on.') - parser.add_argument('--empty', action='store_true', help="Do nothing.") + parser.add_argument( + "args", + metavar="app_label", + nargs="*", + help="Specify the app label(s) to works on.", + ) + parser.add_argument("--empty", action="store_true", help="Do nothing.") def handle(self, *app_labels, **options): app_labels = set(app_labels) - if options['empty']: + if options["empty"]: self.stdout.write() self.stdout.write("Dave, I can't do that.") return @@ -21,7 +26,7 @@ class Command(BaseCommand): # raise an error if some --parameter is flowing from options to args for app_label in app_labels: - if app_label.startswith('--'): + if app_label.startswith("--"): raise CommandError("Sorry, Dave, I can't let you do that.") self.stdout.write("Dave, my mind is going. I can feel it. I can feel it.") diff --git a/tests/user_commands/management/commands/mutually_exclusive_required.py b/tests/user_commands/management/commands/mutually_exclusive_required.py index 8e48f12658..421b3cbbdd 100644 --- a/tests/user_commands/management/commands/mutually_exclusive_required.py +++ b/tests/user_commands/management/commands/mutually_exclusive_required.py @@ -2,19 +2,18 @@ from django.core.management.base import BaseCommand class Command(BaseCommand): - def add_arguments(self, parser): group = parser.add_mutually_exclusive_group(required=True) - group.add_argument('--foo-id', type=int, nargs='?', default=None) - group.add_argument('--foo-name', type=str, nargs='?', default=None) - group.add_argument('--foo-list', type=int, nargs='+') - group.add_argument('--append_const', action='append_const', const=42) - group.add_argument('--const', action='store_const', const=31) - group.add_argument('--count', action='count') - group.add_argument('--flag_false', action='store_false') - group.add_argument('--flag_true', action='store_true') + group.add_argument("--foo-id", type=int, nargs="?", default=None) + group.add_argument("--foo-name", type=str, nargs="?", default=None) + group.add_argument("--foo-list", type=int, nargs="+") + group.add_argument("--append_const", action="append_const", const=42) + group.add_argument("--const", action="store_const", const=31) + group.add_argument("--count", action="count") + group.add_argument("--flag_false", action="store_false") + group.add_argument("--flag_true", action="store_true") def handle(self, *args, **options): for option, value in options.items(): if value is not None: - self.stdout.write('%s=%s' % (option, value)) + self.stdout.write("%s=%s" % (option, value)) diff --git a/tests/user_commands/management/commands/mutually_exclusive_required_with_same_dest.py b/tests/user_commands/management/commands/mutually_exclusive_required_with_same_dest.py index 1a9ab5576d..f6c9fc63a1 100644 --- a/tests/user_commands/management/commands/mutually_exclusive_required_with_same_dest.py +++ b/tests/user_commands/management/commands/mutually_exclusive_required_with_same_dest.py @@ -4,10 +4,10 @@ from django.core.management.base import BaseCommand class Command(BaseCommand): def add_arguments(self, parser): group = parser.add_mutually_exclusive_group(required=True) - group.add_argument('--for', dest='until', action='store') - group.add_argument('--until', action='store') + group.add_argument("--for", dest="until", action="store") + group.add_argument("--until", action="store") def handle(self, *args, **options): for option, value in options.items(): if value is not None: - self.stdout.write('%s=%s' % (option, value)) + self.stdout.write("%s=%s" % (option, value)) diff --git a/tests/user_commands/management/commands/no_translations.py b/tests/user_commands/management/commands/no_translations.py index 2a8af6605b..fd1b6255f7 100644 --- a/tests/user_commands/management/commands/no_translations.py +++ b/tests/user_commands/management/commands/no_translations.py @@ -3,7 +3,6 @@ from django.utils import translation class Command(BaseCommand): - @no_translations def handle(self, *args, **options): return translation.get_language() diff --git a/tests/user_commands/management/commands/outputwrapper.py b/tests/user_commands/management/commands/outputwrapper.py index bafc30d128..0bff3a49fb 100644 --- a/tests/user_commands/management/commands/outputwrapper.py +++ b/tests/user_commands/management/commands/outputwrapper.py @@ -3,6 +3,6 @@ from django.core.management.base import BaseCommand class Command(BaseCommand): def handle(self, **options): - self.stdout.write('Working...') + self.stdout.write("Working...") self.stdout.flush() - self.stdout.write('OK') + self.stdout.write("OK") diff --git a/tests/user_commands/management/commands/required_constant_option.py b/tests/user_commands/management/commands/required_constant_option.py index 121bfcc28c..5395aac236 100644 --- a/tests/user_commands/management/commands/required_constant_option.py +++ b/tests/user_commands/management/commands/required_constant_option.py @@ -4,17 +4,17 @@ from django.core.management.base import BaseCommand class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument( - '--append_const', - action='append_const', + "--append_const", + action="append_const", const=42, required=True, ) - parser.add_argument('--const', action='store_const', const=31, required=True) - parser.add_argument('--count', action='count', required=True) - parser.add_argument('--flag_false', action='store_false', required=True) - parser.add_argument('--flag_true', action='store_true', required=True) + parser.add_argument("--const", action="store_const", const=31, required=True) + parser.add_argument("--count", action="count", required=True) + parser.add_argument("--flag_false", action="store_false", required=True) + parser.add_argument("--flag_true", action="store_true", required=True) def handle(self, *args, **options): for option, value in options.items(): if value is not None: - self.stdout.write('%s=%s' % (option, value)) + self.stdout.write("%s=%s" % (option, value)) diff --git a/tests/user_commands/management/commands/required_list_option.py b/tests/user_commands/management/commands/required_list_option.py index 84f39f0142..bbff9b53f6 100644 --- a/tests/user_commands/management/commands/required_list_option.py +++ b/tests/user_commands/management/commands/required_list_option.py @@ -3,8 +3,8 @@ from django.core.management.base import BaseCommand class Command(BaseCommand): def add_arguments(self, parser): - parser.add_argument('--foo-list', nargs='+', type=int, required=True) + parser.add_argument("--foo-list", nargs="+", type=int, required=True) def handle(self, *args, **options): for option, value in options.items(): - self.stdout.write('%s=%s' % (option, value)) + self.stdout.write("%s=%s" % (option, value)) diff --git a/tests/user_commands/management/commands/required_option.py b/tests/user_commands/management/commands/required_option.py index 3b30ed942e..da84702189 100644 --- a/tests/user_commands/management/commands/required_option.py +++ b/tests/user_commands/management/commands/required_option.py @@ -2,10 +2,9 @@ from django.core.management.base import BaseCommand class Command(BaseCommand): - def add_arguments(self, parser): - parser.add_argument('-n', '--need-me', required=True) - parser.add_argument('-t', '--need-me-too', required=True, dest='needme2') + parser.add_argument("-n", "--need-me", required=True) + parser.add_argument("-t", "--need-me-too", required=True, dest="needme2") def handle(self, *args, **options): - self.stdout.write(','.join(options)) + self.stdout.write(",".join(options)) diff --git a/tests/user_commands/management/commands/reverse_url.py b/tests/user_commands/management/commands/reverse_url.py index 2f88eda62e..b1fb5ad8ec 100644 --- a/tests/user_commands/management/commands/reverse_url.py +++ b/tests/user_commands/management/commands/reverse_url.py @@ -6,5 +6,6 @@ class Command(BaseCommand): """ This command returns a URL from a reverse() call. """ + def handle(self, *args, **options): - return reverse('some_url') + return reverse("some_url") diff --git a/tests/user_commands/management/commands/set_option.py b/tests/user_commands/management/commands/set_option.py index a6e3c9bb6a..5f8c01e541 100644 --- a/tests/user_commands/management/commands/set_option.py +++ b/tests/user_commands/management/commands/set_option.py @@ -2,9 +2,8 @@ from django.core.management.base import BaseCommand class Command(BaseCommand): - def add_arguments(self, parser): - parser.add_argument('--set') + parser.add_argument("--set") def handle(self, **options): - self.stdout.write('Set %s' % options['set']) + self.stdout.write("Set %s" % options["set"]) diff --git a/tests/user_commands/management/commands/subparser.py b/tests/user_commands/management/commands/subparser.py index d3006bd3e8..908a9f2976 100644 --- a/tests/user_commands/management/commands/subparser.py +++ b/tests/user_commands/management/commands/subparser.py @@ -2,11 +2,10 @@ from django.core.management.base import BaseCommand class Command(BaseCommand): - def add_arguments(self, parser): subparsers = parser.add_subparsers() - parser_foo = subparsers.add_parser('foo') - parser_foo.add_argument('bar', type=int) + parser_foo = subparsers.add_parser("foo") + parser_foo.add_argument("bar", type=int) def handle(self, *args, **options): - self.stdout.write(','.join(options)) + self.stdout.write(",".join(options)) diff --git a/tests/user_commands/management/commands/subparser_dest.py b/tests/user_commands/management/commands/subparser_dest.py index 000078911d..cc2ebb5272 100644 --- a/tests/user_commands/management/commands/subparser_dest.py +++ b/tests/user_commands/management/commands/subparser_dest.py @@ -3,9 +3,9 @@ from django.core.management.base import BaseCommand class Command(BaseCommand): def add_arguments(self, parser): - subparsers = parser.add_subparsers(dest='subcommand', required=True) - parser_foo = subparsers.add_parser('foo') - parser_foo.add_argument('--bar') + subparsers = parser.add_subparsers(dest="subcommand", required=True) + parser_foo = subparsers.add_parser("foo") + parser_foo.add_argument("--bar") def handle(self, *args, **options): - self.stdout.write(','.join(options)) + self.stdout.write(",".join(options)) diff --git a/tests/user_commands/management/commands/subparser_required.py b/tests/user_commands/management/commands/subparser_required.py index 995b0dce66..e9bff79752 100644 --- a/tests/user_commands/management/commands/subparser_required.py +++ b/tests/user_commands/management/commands/subparser_required.py @@ -3,11 +3,11 @@ from django.core.management.base import BaseCommand class Command(BaseCommand): def add_arguments(self, parser): - subparsers_1 = parser.add_subparsers(dest='subcommand_1') - parser_foo_1 = subparsers_1.add_parser('foo_1') - subparsers_2 = parser_foo_1.add_subparsers(dest='subcommand_2') - parser_foo_2 = subparsers_2.add_parser('foo_2') - parser_foo_2.add_argument('--bar', required=True) + subparsers_1 = parser.add_subparsers(dest="subcommand_1") + parser_foo_1 = subparsers_1.add_parser("foo_1") + subparsers_2 = parser_foo_1.add_subparsers(dest="subcommand_2") + parser_foo_2 = subparsers_2.add_parser("foo_2") + parser_foo_2.add_argument("--bar", required=True) def handle(self, *args, **options): - self.stdout.write(','.join(options)) + self.stdout.write(",".join(options)) diff --git a/tests/user_commands/management/commands/transaction.py b/tests/user_commands/management/commands/transaction.py index ca531b2b97..f8e28ff7ea 100644 --- a/tests/user_commands/management/commands/transaction.py +++ b/tests/user_commands/management/commands/transaction.py @@ -3,8 +3,8 @@ from django.core.management.base import BaseCommand class Command(BaseCommand): help = "Say hello." - args = '' + args = "" output_transaction = True def handle(self, *args, **options): - return 'Hello!' + return "Hello!" |