Fixed #20437 - marked a test-runner test as expected-fail under certain conditions.

This commit is contained in:
Carl Meyer 2013-05-20 01:56:23 -04:00
parent 022de7e139
commit a7dc13ec23
1 changed files with 17 additions and 0 deletions

View File

@ -1,8 +1,22 @@
from contextlib import contextmanager from contextlib import contextmanager
import os import os
import sys
from django.test import TestCase from django.test import TestCase
from django.test.runner import DiscoverRunner from django.test.runner import DiscoverRunner
from django.utils.unittest import expectedFailure
try:
import unittest2
except ImportError:
unittest2 = None
def expectedFailureIf(condition):
"""Marks a test as an expected failure if ``condition`` is met."""
if condition:
return expectedFailure
return lambda func: func
class DiscoverRunnerTest(TestCase): class DiscoverRunnerTest(TestCase):
@ -35,6 +49,9 @@ class DiscoverRunnerTest(TestCase):
self.assertEqual(count, 1) self.assertEqual(count, 1)
# this test fails if unittest2 is installed from PyPI on Python 2.6
# refs https://code.djangoproject.com/ticket/20437
@expectedFailureIf(sys.version_info < (2, 7) and unittest2)
def test_dotted_test_method_vanilla_unittest(self): def test_dotted_test_method_vanilla_unittest(self):
count = DiscoverRunner().build_suite( count = DiscoverRunner().build_suite(
["test_discovery_sample.tests_sample.TestVanillaUnittest.test_sample"], ["test_discovery_sample.tests_sample.TestVanillaUnittest.test_sample"],