commit 9d25f78e203af09202125f27f9fd6cac5c893e4d
Author: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Date: Thu Sep 5 13:58:47 2019 +0200
test
diff --git a/tests/user_commands/management/commands/mutually_exclusive_required.py b/tests/user_commands/management/commands/mutually_exclusive_required.py
new file mode 100644
index 0000000000..00b5b07bd1
-
|
+
|
|
| 1 | from django.core.management.base import BaseCommand |
| 2 | |
| 3 | |
| 4 | class Command(BaseCommand): |
| 5 | |
| 6 | def add_arguments(self, parser): |
| 7 | group = parser.add_mutually_exclusive_group(required=True) |
| 8 | group.add_argument('--shop-id', nargs='?', type=int, default=None, dest='shop_id') |
| 9 | group.add_argument('--shop', nargs='?', type=str, default=None, dest='shop_name') |
| 10 | |
| 11 | def handle(self, *args, **options): |
| 12 | self.stdout.write(','.join(options)) |
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
index a53c781ac6..088fda4090 100644
a
|
b
|
class CommandTests(SimpleTestCase):
|
214 | 214 | management.call_command('common_args', stdout=out) |
215 | 215 | self.assertIn('Detected that --version already exists', out.getvalue()) |
216 | 216 | |
| 217 | def test_mutually_exclusive_required(self): |
| 218 | out = StringIO() |
| 219 | management.call_command('mutually_exclusive_required', shop_id=1, stdout=out) |
| 220 | self.assertIn('shop_id', out.getvalue()) |
| 221 | management.call_command('mutually_exclusive_required', shop_name='foo', stdout=out) |
| 222 | self.assertIn('shop_name', out.getvalue()) |
| 223 | |
217 | 224 | def test_subparser(self): |
218 | 225 | out = StringIO() |
219 | 226 | management.call_command('subparser', 'foo', 12, stdout=out) |