From ec0ff406311de88f4e2a135d784363424fe602aa Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 19 Jan 2021 08:35:16 +0100 Subject: Fixed #32355 -- Dropped support for Python 3.6 and 3.7 --- .../management/commands/subparser_dest.py | 4 +--- tests/user_commands/tests.py | 18 +++--------------- 2 files changed, 4 insertions(+), 18 deletions(-) (limited to 'tests/user_commands') diff --git a/tests/user_commands/management/commands/subparser_dest.py b/tests/user_commands/management/commands/subparser_dest.py index ffea7efac7..000078911d 100644 --- a/tests/user_commands/management/commands/subparser_dest.py +++ b/tests/user_commands/management/commands/subparser_dest.py @@ -1,11 +1,9 @@ from django.core.management.base import BaseCommand -from django.utils.version import PY37 class Command(BaseCommand): def add_arguments(self, parser): - kwargs = {'required': True} if PY37 else {} - subparsers = parser.add_subparsers(dest='subcommand', **kwargs) + subparsers = parser.add_subparsers(dest='subcommand', required=True) parser_foo = subparsers.add_parser('foo') parser_foo.add_argument('--bar') diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py index 9262e2717a..05415717c6 100644 --- a/tests/user_commands/tests.py +++ b/tests/user_commands/tests.py @@ -17,7 +17,6 @@ from django.test import SimpleTestCase, override_settings from django.test.utils import captured_stderr, extend_sys_path, ignore_warnings from django.utils import translation from django.utils.deprecation import RemovedInDjango41Warning -from django.utils.version import PY37 from .management.commands import dance @@ -337,20 +336,9 @@ class CommandTests(SimpleTestCase): msg = "Error: invalid choice: 'test' (choose from 'foo')" with self.assertRaisesMessage(CommandError, msg): management.call_command('subparser', 'test', 12) - if PY37: - # "required" option requires Python 3.7 and later. - msg = 'Error: the following arguments are required: subcommand' - with self.assertRaisesMessage(CommandError, msg): - management.call_command('subparser_dest', subcommand='foo', bar=12) - else: - msg = ( - 'Unknown option(s) for subparser_dest command: subcommand. ' - 'Valid options are: bar, force_color, help, no_color, ' - 'pythonpath, settings, skip_checks, stderr, stdout, ' - 'traceback, verbosity, version.' - ) - with self.assertRaisesMessage(TypeError, msg): - management.call_command('subparser_dest', subcommand='foo', bar=12) + msg = 'Error: the following arguments are required: subcommand' + with self.assertRaisesMessage(CommandError, msg): + management.call_command('subparser_dest', subcommand='foo', bar=12) def test_create_parser_kwargs(self): """BaseCommand.create_parser() passes kwargs to CommandParser.""" -- cgit v1.3