Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
run: |
source <(cargo llvm-cov show-env --export-prefix)
.venv/bin/maturin develop
- name: Lint test files
run: |
.venv/bin/ruff check
- name: Test with pytest
run: |
source <(cargo llvm-cov show-env --export-prefix)
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,14 @@ python-source = "python"

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "tests.settings"

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["F"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []
2 changes: 2 additions & 0 deletions python/django_rusty_templates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from .django_rusty_templates import Engine, Template

__all__ = ["RustyTemplates", "Template"]


class RustyTemplates(BaseEngine):
app_dirname = "templates"
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ django
maturin
pytest
pytest-django
ruff
6 changes: 3 additions & 3 deletions tests/filters/test_add.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from django.template import engines
from django.template.exceptions import TemplateSyntaxError
from django.template.base import VariableDoesNotExist
from django.template.exceptions import TemplateSyntaxError


def test_add_integers():
Expand Down Expand Up @@ -121,12 +121,12 @@ def test_add_missing_argument():
template = "{{ foo|add }}"

with pytest.raises(TemplateSyntaxError) as exc_info:
django_template = engines["django"].from_string(template)
engines["django"].from_string(template)

assert str(exc_info.value) == "add requires 2 arguments, 1 provided"

with pytest.raises(TemplateSyntaxError) as exc_info:
rust_template = engines["rusty"].from_string(template)
engines["rusty"].from_string(template)

assert str(exc_info.value) == """
× Expected an argument
Expand Down
5 changes: 2 additions & 3 deletions tests/filters/test_addslashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""

import pytest
from django.template import engines
from django.utils.safestring import mark_safe


Expand All @@ -31,8 +30,8 @@
"""@setup({"addslashes02": "{{ a|addslashes }} {{ b|addslashes }}"})"""
template = "{{ a|addslashes }} {{ b|addslashes }}"

django_template = engines["django"].from_string(template)
rust_template = engines["rusty"].from_string(template)
django_template = engines["django"].from_string(template) # noqa
rust_template = engines["rusty"].from_string(template) # noqa

Check warning on line 34 in tests/filters/test_addslashes.py

View check run for this annotation

Codecov / codecov/patch

tests/filters/test_addslashes.py#L33-L34

Added lines #L33 - L34 were not covered by tests
Comment on lines +33 to +34
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed it when reviewing before, but I think the reason ruff is complaining is because django_template and rust_template are unused.

Both test_addslashes01 and test_addslashes02 refer to a self.engine, but this doesn't exist because these aren't methods on a unittest test class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #57


output = self.engine.render_to_string(
"addslashes02", {"a": "<a>'", "b": mark_safe("<a>'")}
Expand Down
1 change: 0 additions & 1 deletion tests/test_django.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pathlib import Path
from textwrap import dedent

import pytest
from django.template import engines
Expand Down