Skip to content

Commit a0ec1d6

Browse files
committed
fix tests for coverage
1 parent b5df522 commit a0ec1d6

File tree

5 files changed

+50
-514
lines changed

5 files changed

+50
-514
lines changed

justfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ install-uv:
3232
# setup the venv and pre-commit hooks
3333
setup python="python":
3434
uv venv -p {{ python }}
35-
@just run pre-commit install
35+
@just install-precommit
3636

3737
# install git pre-commit hooks
3838
install-precommit:
39-
@just run pre-commit install
39+
uv run pre-commit install
4040

4141
# update and install development dependencies
4242
install *OPTS:
4343
uv sync --all-extras {{ OPTS }}
44-
@just run pre-commit install
44+
@just install-precommit
4545

4646
# install without extra dependencies
4747
install-basic:
@@ -187,8 +187,8 @@ check: check-lint check-format check-types check-package check-docs check-docs-l
187187

188188
# run all tests
189189
test-all:
190-
uv run --all-extras pytest --cov-append
191-
uv run --extra PyYAML --extra Jinja2 pytest --cov-append
190+
uv run --all-extras --exact --group test --no-dev pytest --cov-append
191+
uv run --no-extra PyYAML --no-extra Jinja2 --exact --group test --no-dev pytest --cov-append
192192

193193
# run tests
194194
test *TESTS:

pyproject.toml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,33 @@ Jinja2 = ["Jinja2>=2.9,<4.0"]
6767
"Code_of_Conduct" = "https://github.com/bckohan/django-render-static/blob/main/CODE_OF_CONDUCT.md"
6868

6969
[dependency-groups]
70+
test = [
71+
# precommit has a transitive dependency on pyyaml which messes up our tests
72+
# so we have to have a separate test group
73+
"deepdiff>=8.3.0",
74+
"django-enum>=2.1.0",
75+
"enum-properties>=2.2.2",
76+
"pytest>=8.3.5",
77+
"pytest-cov>=6.0.0",
78+
"pytest-django>=4.10.0",
79+
"python-dateutil>=2.9.0.post0",
80+
"selenium>=4.29.0",
81+
"webdriver-manager>=4.0.2",
82+
]
7083
dev = [
71-
"aiohttp>=3.11.13",
7284
"deepdiff>=8.3.0",
7385
"django-enum>=2.1.0",
7486
"django-stubs[compatible-mypy]>=5.1.3",
7587
"enum-properties>=2.2.2",
76-
"importlib-metadata>=8.6.1",
7788
"ipdb>=0.13.13",
7889
"ipython>=8.18.1",
7990
"mypy>=1.15.0",
80-
"pre-commit>=4.1.0",
8191
"pyright>=1.1.396",
8292
"pytest>=8.3.5",
8393
"pytest-cov>=6.0.0",
8494
"pytest-django>=4.10.0",
8595
"python-dateutil>=2.9.0.post0",
96+
"pre-commit>=4.1.0",
8697
"ruff>=0.9.10",
8798
"selenium>=4.29.0",
8899
"tomlkit>=0.13.2",

src/render_static/loaders/django.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def get_contents(self, origin: Origin) -> str:
101101
if Path(origin.name).is_dir():
102102
self.is_dir = True
103103
return ""
104-
raise
104+
raise # pragma: no cover
105105

106106
def search(self, prefix: str) -> Generator[Template, None, None]:
107107
"""

tests/test_yaml.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66
from django.core.management import call_command
77
from django.test import override_settings
8-
8+
from render_static.context import InvalidContext
99
from tests.test_core import (
1010
APP1_STATIC_DIR,
1111
EXPECTED_DIR,
@@ -19,14 +19,19 @@
1919
yaml = None
2020

2121

22-
@pytest.mark.skipif(not yaml, reason="PyYAML is not installed")
2322
class TestYAMLContext(BaseTestCase):
23+
@pytest.mark.skipif(not yaml, reason="PyYAML is not installed")
2424
def test_yaml_context(self):
2525
self.assertEqual(
2626
resolve_context(str(Path(__file__).parent / "resources" / "context.yaml")),
2727
{"context": "yaml"},
2828
)
2929

30+
@pytest.mark.skipif(yaml is not None, reason="PyYAML is installed")
31+
def test_yaml_uninstalled_context(self):
32+
with self.assertRaises(InvalidContext):
33+
resolve_context(str(Path(__file__).parent / "resources" / "context.yaml"))
34+
3035

3136
@pytest.mark.skipif(not yaml, reason="PyYAML is not installed")
3237
@override_settings(

0 commit comments

Comments
 (0)