File tree 4 files changed +64
-2
lines changed
4 files changed +64
-2
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ source = "https://github.com/bittner/django-bootstrap-static"
42
42
43
43
[tool .pytest .ini_options ]
44
44
addopts = " --color=yes --doctest-modules --verbose"
45
+ python_files = [" tests.py" , " test_*.py" , " *_tests.py" ]
46
+ pythonpath = [" tests" ]
47
+ DJANGO_SETTINGS_MODULE = " test_project.settings"
48
+ FAIL_INVALID_TEMPLATE_VARS = true
45
49
46
50
[tool .ruff ]
47
51
extend-exclude = []
Original file line number Diff line number Diff line change
1
+ """Minimal Django settings for test project."""
2
+
3
+ INSTALLED_APPS = [
4
+ "django.contrib.staticfiles" ,
5
+ "bootstrap" ,
6
+ "fontawesome" ,
7
+ ]
8
+
9
+ TEMPLATES = [
10
+ {
11
+ "BACKEND" : "django.template.backends.django.DjangoTemplates" ,
12
+ "DIRS" : [],
13
+ "APP_DIRS" : True ,
14
+ "OPTIONS" : {
15
+ "context_processors" : [
16
+ "django.template.context_processors.request" ,
17
+ ],
18
+ },
19
+ },
20
+ ]
21
+
22
+ STATIC_URL = "static"
Original file line number Diff line number Diff line change
1
+ """Tests for Django templates."""
2
+
3
+ from django .template import Context , Template
4
+
5
+ template = """
6
+ {% load static %}
7
+ <head>
8
+ <link rel="stylesheet" href="{% static 'bootstrap/css/bootstrap.min.css' %}">
9
+ <script defer src="{% static 'fontawesome/js/all.min.js' %}"></script>
10
+ </head>
11
+ <body>
12
+ ...
13
+ <script src="{% static 'bootstrap/js/jquery.min.js' %}"></script>
14
+ <script src="{% static 'bootstrap/js/bootstrap.bundle.min.js' %}"></script>
15
+ </body>
16
+ """
17
+
18
+
19
+ def test_template ():
20
+ """Importing the package should work as described in the README."""
21
+ bootstrap_min_css = "bootstrap/css/bootstrap.min.css"
22
+ bootstrap_min_js = "bootstrap/js/bootstrap.bundle.min.js"
23
+ fontawesome_min_js = "fontawesome/js/all.min.js"
24
+ jquery_min_js = "bootstrap/js/jquery.min.js"
25
+
26
+ c = Context ()
27
+ t = Template (template )
28
+ html = t .render (c )
29
+
30
+ assert f'<link rel="stylesheet" href="/static/{ bootstrap_min_css } ">' in html
31
+ assert f'<script defer src="/static/{ fontawesome_min_js } "></script>' in html
32
+ assert f'<script src="/static/{ jquery_min_js } "></script>' in html
33
+ assert f'<script src="/static/{ bootstrap_min_js } "></script>' in html
Original file line number Diff line number Diff line change @@ -6,8 +6,11 @@ envlist =
6
6
7
7
[testenv]
8
8
description = Unit tests and test coverage
9
- deps = pytest
10
- commands = pytest {posargs}
9
+ deps =
10
+ django
11
+ pytest-django
12
+ commands =
13
+ pytest {posargs}
11
14
12
15
[testenv:clean]
13
16
description = Remove bytecode and other debris
You can’t perform that action at this time.
0 commit comments