Coverage for tests/test_app/management/commands/dj_params3.py: 87%

21 statements  

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

1from django.core.management import CommandError 

2 

3from django_typer import TyperCommand, command, initialize, types 

4from django_typer.tests.utils import log_django_parameters 

5 

6 

7class Command(TyperCommand): 

8 help = "Test that django parameters work as expected" 

9 

10 @initialize() 

11 def init(self, verbosity: types.Verbosity = 1): 

12 """ 

13 The callback to initialize the command. 

14 """ 

15 assert self.__class__ == Command 

16 self.verbosity = verbosity 

17 

18 @command() 

19 def cmd1(self, throw: bool = False): 

20 assert self.__class__ == Command 

21 log_django_parameters(self, verbosity=self.verbosity) 

22 if throw: 22 ↛ 23line 22 didn't jump to line 23, because the condition on line 22 was never true

23 raise CommandError("Test Exception") 

24 

25 @command() 

26 def cmd2(self, throw: bool = False): 

27 assert self.__class__ == Command 

28 log_django_parameters(self, verbosity=self.verbosity) 

29 if throw: 29 ↛ 30line 29 didn't jump to line 30, because the condition on line 29 was never true

30 raise CommandError("Test Exception")