Coverage for tests/test_app/management/commands/help_precedence3.py: 71%

13 statements  

« prev     ^ index     » next       coverage.py v7.3.4, created at 2024-01-20 18:02 +0000

1import json 

2 

3from django.utils.translation import gettext_lazy as _ 

4 

5from django_typer import TyperCommand, command, initialize 

6 

7 

8class Command(TyperCommand): 

9 @initialize(help=_("Test minimal TyperCommand subclass - callback method")) 

10 def init(self, verbosity: int = 1): 

11 """ 

12 Test minimal TyperCommand subclass - callback docstring 

13 """ 

14 assert self.__class__ is Command 

15 self.verbosity = verbosity 

16 

17 @command(help=_("Test minimal TyperCommand subclass - command method")) 

18 def handle(self, arg1: str, arg2: str, arg3: float = 0.5, arg4: int = 1): 

19 """ 

20 Test minimal TyperCommand subclass - docstring 

21 """ 

22 assert self.__class__ == Command 

23 opts = {"arg1": arg1, "arg2": arg2, "arg3": arg3, "arg4": arg4} 

24 return json.dumps(opts)