Skip to content

Commit

Permalink
add completion test with no TEMPLATES configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan committed Jan 7, 2025
1 parent 3e92759 commit f95a5bf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion 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 TypeError:
except (AttributeError, TypeError):
# 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 Down
14 changes: 7 additions & 7 deletions doc/source/shell_completion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ or have solutions, please `report them on our discussions page <https://github.c

.. code-block:: bash
zstyle ':completion:*' menu select
if type brew &>/dev/null; then
FPATH=~/.zfunc:$(brew --prefix)/share/zsh-completions:$FPATH
autoload -Uz compinit
compinit
fpath=(~/.zfunc $(brew --prefix)/share/zsh-completions $fpath)
else
fpath=(~/.zfunc $fpath)
fi
fpath+=~/.zfunc
autoload -Uz compinit
compinit
zstyle ':completion:*' menu select
.. tip::

Expand Down
2 changes: 1 addition & 1 deletion tests/shellcompletion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from shellingham import detect_shell

from django.test import TestCase
from django.test import TestCase, override_settings
from django_typer.management import get_command
from django_typer.management.commands.shellcompletion import (
Command as ShellCompletion,
Expand Down
6 changes: 5 additions & 1 deletion tests/shellcompletion/test_zsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path

import pytest
from django.test import TestCase
from django.test import TestCase, override_settings
import sys
import os

Expand Down Expand Up @@ -54,3 +54,7 @@ def test_no_zshrc_file(self):
finally:
if zshrc:
(Path.home() / ".zshrc").write_text(zshrc)

@override_settings(TEMPLATES=[])
def test_no_template_config(self):
self.test_shell_complete()

0 comments on commit f95a5bf

Please sign in to comment.