Skip to content

Commit 6143f18

Browse files
committed
Test to illustrate poor xmlrunner.extra.djangotestrunner.XMLTestRunner extensibility
1 parent 14fa2ff commit 6143f18

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

tests/django_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
from os import path
66
import glob
7+
import mock
78
import tempfile
89
import shutil
910

@@ -129,3 +130,20 @@ def test_django_multiple_reports(self):
129130
self.assertTrue(test_files,
130131
'did not generate xml reports where expected.')
131132
self.assertEqual(2, len(test_files))
133+
134+
def test_django_runner_extension(self):
135+
from xmlrunner.extra.djangotestrunner import XMLTestRunner
136+
137+
class MyDjangoRunner(XMLTestRunner):
138+
test_runner = mock.Mock()
139+
140+
self._override_settings(
141+
TEST_OUTPUT_DIR=self.tmpdir,
142+
TEST_OUTPUT_VERBOSE=0)
143+
apps.populate(settings.INSTALLED_APPS)
144+
145+
runner = MyDjangoRunner()
146+
suite = runner.build_suite(test_labels=None)
147+
runner.run_suite(suite)
148+
149+
self.assertTrue(MyDjangoRunner.test_runner.called)

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ deps =
1414
djangolts: django>=1.8.8,<1.9.0
1515
djangocurr: django>=1.9.1
1616
lxml>=3.6.0
17+
mock
1718
commands =
1819
coverage run --append setup.py test
1920
coverage report --omit='.tox/*'

0 commit comments

Comments
 (0)