@@ -122,35 +122,7 @@ def test_ignore(client):
122
122
ROOT_URLCONF = 'tpkg.app.urls'
123
123
"""
124
124
)
125
- def test_invalid_template_variable2 (django_testdir ):
126
- django_testdir .create_app_file (
127
- """
128
- from django.conf.urls import url
129
- from pytest_django_test.compat import patterns
130
-
131
- from tpkg.app import views
132
-
133
- urlpatterns = patterns(
134
- '',
135
- url(r'the_view/', views.the_view),
136
- )
137
- """ ,
138
- "urls.py" ,
139
- )
140
- django_testdir .create_app_file (
141
- """
142
- from django.shortcuts import render
143
-
144
-
145
- def the_view(request):
146
- return render(
147
- request=request,
148
- template_name='the_template.html',
149
- context={'data': {'empty': '', 'none': None}},
150
- )
151
- """ ,
152
- "views.py" ,
153
- )
125
+ def test_invalid_template_with_default_if_none (django_testdir ):
154
126
django_testdir .create_app_file (
155
127
"""
156
128
<div>{{ data.empty|default:'d' }}</div>
@@ -163,14 +135,19 @@ def the_view(request):
163
135
)
164
136
django_testdir .create_test_module (
165
137
"""
166
- import pytest
138
+ def test_for_invalid_template():
139
+ from django.shortcuts import render
167
140
168
- def test_for_invalid_template(client):
169
- client.get('/the_view/')
141
+
142
+ render(
143
+ request=None,
144
+ template_name='the_template.html',
145
+ context={'data': {'empty': '', 'none': None}},
146
+ )
170
147
"""
171
148
)
172
- result = django_testdir .runpytest_subprocess ("-s" , "- -fail-on-template-vars" )
173
- result .stdout .fnmatch_lines_random (
149
+ result = django_testdir .runpytest_subprocess ("--fail-on-template-vars" )
150
+ result .stdout .fnmatch_lines (
174
151
[
175
152
"tpkg/test_the_test.py F" ,
176
153
"E * Failed: Undefined template variable 'data.missing' in *the_template.html'" ,
0 commit comments