Skip to content

Commit 6c3fce9

Browse files
committed
The other-engine tests use a different directory, to be sure
1 parent 97ddfee commit 6c3fce9

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

tests/plugin_test.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,12 @@ def test_settings():
7272
class DjangoPluginTestCase(TempDirMixin, TestCase):
7373
"""A base class for all our tests."""
7474

75-
def path(self, name=None):
76-
return "templates/{}".format(name or self.template_file)
75+
def setUp(self):
76+
super(DjangoPluginTestCase, self).setUp()
77+
self.template_directory = "templates"
78+
79+
def _path(self, name=None):
80+
return "{}/{}".format(self.template_directory, name or self.template_file)
7781

7882
def make_template(self, text, name=None):
7983
"""Make a template with `text`.
@@ -86,7 +90,7 @@ def make_template(self, text, name=None):
8690
self.template_file = name
8791
else:
8892
self.template_file = self.id().rpartition(".")[2] + ".html"
89-
template_path = self.path(self.template_file)
93+
template_path = self._path(self.template_file)
9094
return os.path.abspath(self.make_file(template_path, text))
9195

9296
def run_django_coverage(
@@ -144,7 +148,7 @@ def get_line_data(self, name=None):
144148
list: the line numbers of lines executed in the template.
145149
146150
"""
147-
path = self.path(name)
151+
path = self._path(name)
148152
line_data = self.cov.data.line_data()[os.path.realpath(path)]
149153
return line_data
150154

@@ -156,7 +160,7 @@ def get_analysis(self, name=None):
156160
numbers of missed lines.
157161
158162
"""
159-
path = self.path(name)
163+
path = self._path(name)
160164
analysis = self.cov.analysis2(os.path.abspath(path))
161165
_, executable, _, missing, _ = analysis
162166
return executable, missing
@@ -190,7 +194,7 @@ def get_html_report(self, name=None):
190194
float: the total percentage covered.
191195
192196
"""
193-
path = self.path(name)
197+
path = self._path(name)
194198
html_coverage = self.cov.html_report(os.path.abspath(path))
195199
return html_coverage
196200

@@ -201,7 +205,7 @@ def get_xml_report(self, name=None):
201205
float: the total percentage covered.
202206
203207
"""
204-
path = self.path(name)
208+
path = self._path(name)
205209
xml_coverage = self.cov.xml_report(os.path.abspath(path))
206210
return xml_coverage
207211

tests/test_engines.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def setUp(self):
1616
engine = {
1717
'NAME': 'other',
1818
'BACKEND': 'django.template.backends.django.DjangoTemplates',
19-
'DIRS': ['templates'], # where the tests put things.
19+
'DIRS': ['templates2'], # where the tests put things.
2020
'OPTIONS': {
2121
'debug': True,
2222
},
@@ -25,6 +25,8 @@ def setUp(self):
2525
modified_settings.enable()
2626
self.addCleanup(modified_settings.disable)
2727

28+
self.template_directory = 'templates2'
29+
2830
def test_file_template(self):
2931
self.make_template('Hello')
3032
text = self.run_django_coverage(using='other')

0 commit comments

Comments
 (0)