Skip to content

Commit

Permalink
Don't fail Python tests for missing SVG icons
Browse files Browse the repository at this point in the history
We don't want to have to run the frontend build to run Python tests.
  • Loading branch information
chosak committed Sep 12, 2024
1 parent 12903eb commit 844f245
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
11 changes: 10 additions & 1 deletion settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,22 @@
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [BASE_DIR / "viewer/static/icons"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"viewer.context_processors.crawl_stats",
],
"loaders": [
(
"django.template.loaders.cached.Loader",
[
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
"viewer.loader.IgnoreMissingSVGsTemplateLoader",
],
),
],
},
},
]
Expand Down
16 changes: 16 additions & 0 deletions viewer/loader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import re

from django.template.base import Origin
from django.template.loaders.base import Loader


SVG_FILENAME = re.compile(r"^.*\.svg$")


class IgnoreMissingSVGsTemplateLoader(Loader):
def get_template_sources(self, template_name):
if SVG_FILENAME.match(template_name): # pragma: no branch
yield Origin(template_name, template_name, loader=self)

def get_contents(self, origin):
return ""

0 comments on commit 844f245

Please sign in to comment.