Created
October 28, 2010 18:56
-
-
Save coderanger/652068 to your computer and use it in GitHub Desktop.
XML report generation for Django unittests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from django.conf import settings | |
from south.management.commands import test | |
class Command(test.Command): | |
help = test.Command.help.rstrip('.') + ' with special output for Bitten.' | |
def handle(self, *test_labels, **options): | |
os.environ['DJANGO_BITTEN_TEST'] = '1' | |
return super(Command, self).handle(*test_labels, **options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AtariTestSuiteRunner(DjangoTestSuiteRunner): | |
def run_suite(self, suite, **kwargs): | |
if os.environ.get('DJANGO_BITTEN_TEST') == '1': | |
from bitten.util.testrunner import XMLTestRunner | |
xml_output = settings.TEST_XML_OUTPUT | |
output_dir = os.path.dirname(xml_output) or '.' | |
if not os.path.exists(output_dir): | |
os.makedirs(output_dir) | |
xml_output_file = open(xml_output, 'w') | |
return XMLTestRunner(xml_stream=xml_output_file).run(suite) | |
else: | |
return super(AtariTestSuiteRunner, self).run_suite(suite, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment