Skip to content

Commit

Permalink
add tests for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan committed Jan 7, 2025
1 parent f95a5bf commit 69ee3fa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion django_typer/management/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ def __init__(
if param.name
},
)
elif parent:
else:
assert parent
self.django_command = parent.django_command

if supplied_params:
Expand Down
4 changes: 1 addition & 3 deletions django_typer/management/commands/shellcompletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def source(self) -> str:
"""
try:
return self.load_template().render(self.source_vars()) # type: ignore
except (AttributeError, TypeError):
except (AttributeError, TypeError, ValueError):
# it is annoying that get_template() and DjangoEngine.get_template() return different
# interfaces
return self.load_template().render(Context(self.source_vars())) # type: ignore
Expand All @@ -260,14 +260,12 @@ def install(self) -> Path:
This method should return the path to the installed script.
"""
...

@abstractmethod
def uninstall(self):
"""
Deriving classes must implement this method to uninstall the completion script.
"""
...

def process_rich_text(self, text: str) -> str:
"""
Expand Down
11 changes: 11 additions & 0 deletions tests/test_parser_completers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,17 @@ def test_custom_fallback(self):
)[0]
self.assertTrue("shell" in result)

with self.assertRaises(CommandError):
call_command(
"shellcompletion",
"--shell",
SHELL,
"complete",
"--fallback",
"tests.fallback.does_not_exist",
"shell ",
)

def test_import_path_completer(self):
result = run_command(
"shellcompletion", "--shell", SHELL, "complete", "multi --settings "
Expand Down

0 comments on commit 69ee3fa

Please sign in to comment.