Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed AttributeError upon a single skipped test #272

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
3 changes: 3 additions & 0 deletions tests/django_example/app3/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin # NOQA

# Register your models here.
Empty file.
3 changes: 3 additions & 0 deletions tests/django_example/app3/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models # NOQA

# Create your models here.
12 changes: 12 additions & 0 deletions tests/django_example/app3/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from unittest import skipIf

from django.test import TestCase


# Create your tests here.
@skipIf(condition=True, reason=True)
class SkipTestCase(TestCase):
def test_skip(self):
"""Test Skip"""
pass

3 changes: 3 additions & 0 deletions tests/django_example/app3/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render # NOQA

# Create your views here.
2 changes: 1 addition & 1 deletion tests/django_example/example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
SECRET_KEY = 'not-a-secret'
DEBUG = True
ALLOWED_HOSTS = []
INSTALLED_APPS = ['app', 'app2']
INSTALLED_APPS = ['app', 'app2', 'app3']
MIDDLEWARE_CLASSES = []
ROOT_URLCONF = 'example.urls'
TEMPLATES = []
Expand Down
6 changes: 4 additions & 2 deletions tests/django_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ def _override_settings(self, **kwargs):
setattr(self.override, key, new_value)

def _check_runner(self, runner):
suite = runner.build_suite(test_labels=['app2', 'app'])
suite = runner.build_suite(test_labels=['app3', 'app2', 'app'])
test_ids = [test.id() for test in suite]
self.assertEqual(test_ids, [
'app3.tests.SkipTestCase.test_skip',
'app2.tests.DummyTestCase.test_pass',
'app.tests.DummyTestCase.test_negative_comment1',
'app.tests.DummyTestCase.test_negative_comment2',
Expand All @@ -68,6 +69,7 @@ def _check_runner(self, runner):
'app.tests.DummyTestCase.test_negative_comment1',
'app.tests.DummyTestCase.test_negative_comment2',
'app2.tests.DummyTestCase.test_pass',
'app3.tests.SkipTestCase.test_skip',
]))

def test_django_runner(self):
Expand Down Expand Up @@ -135,7 +137,7 @@ def test_django_multiple_reports(self):
test_files = glob.glob(path.join(self.tmpdir, 'TEST*.xml'))
self.assertTrue(test_files,
'did not generate xml reports where expected.')
self.assertEqual(2, len(test_files))
self.assertEqual(3, len(test_files))

def test_django_runner_extension(self):
from xmlrunner.extra.djangotestrunner import XMLTestRunner
Expand Down
2 changes: 1 addition & 1 deletion xmlrunner/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ def _report_testcase(test_result, xml_testsuite, xml_document):
)
result_elem.setAttribute(
'message',
test_result.test_exception_message
str(test_result.test_exception_message)
)
if test_result.get_error_info():
error_info = safe_unicode(test_result.get_error_info())
Expand Down