Skip to content

Commit 2757a85

Browse files
author
Brian Kohan
committed
add inheritance test
1 parent 386f043 commit 2757a85

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

django_typer/tests/apps/test_app/management/commands/help_precedence16.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,11 @@ class Command(BaseCommand, help=None):
1717

1818
def handle(self, arg1: str, arg2: str, arg3: float = 0.5, arg4: int = 1):
1919
assert self.__class__ == Command
20-
opts = {"arg1": arg1, "arg2": arg2, "arg3": arg3, "arg4": arg4}
20+
opts = {
21+
"arg1": arg1,
22+
"arg2": arg2,
23+
"arg3": arg3,
24+
"arg4": arg4,
25+
"class": str(self.__class__),
26+
}
2127
return json.dumps(opts)

django_typer/tests/apps/test_app/management/commands/help_precedence8.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,11 @@ def handle(self, arg1: str, arg2: str, arg3: float = 0.5, arg4: int = 1):
1717
Test minimal TyperCommand subclass - docstring
1818
"""
1919
assert self.__class__ == Command
20-
opts = {"arg1": arg1, "arg2": arg2, "arg3": arg3, "arg4": arg4}
20+
opts = {
21+
"arg1": arg1,
22+
"arg2": arg2,
23+
"arg3": arg3,
24+
"arg4": arg4,
25+
"class": str(self.__class__),
26+
}
2127
return json.dumps(opts)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from django.core.management import call_command
2+
from django.test import TestCase
3+
from django_typer import get_command
4+
from django_typer.tests.utils import run_command
5+
6+
7+
class TestInheritance(TestCase):
8+
def test_handle_override(self):
9+
stdout, _, retcode = run_command("help_precedence8", "1", "2")
10+
self.assertEqual(retcode, 0)
11+
self.assertEqual(
12+
stdout,
13+
{
14+
"arg1": "1",
15+
"arg2": "2",
16+
"arg3": 0.5,
17+
"arg4": 1,
18+
"class": "<class 'django_typer.tests.apps.test_app.management.commands.help_precedence8.Command'>",
19+
},
20+
)
21+
stdout, _, retcode = run_command("help_precedence16", "1", "2")
22+
self.assertEqual(retcode, 0)
23+
self.assertEqual(
24+
stdout,
25+
{
26+
"arg1": "1",
27+
"arg2": "2",
28+
"arg3": 0.5,
29+
"arg4": 1,
30+
"class": "<class 'django_typer.tests.apps.test_app.management.commands.help_precedence16.Command'>",
31+
},
32+
)

0 commit comments

Comments
 (0)