diff --git a/tests/test_runner/test_discover_runner.py b/tests/test_runner/test_discover_runner.py index 030a0bc40a..1a0fb88367 100644 --- a/tests/test_runner/test_discover_runner.py +++ b/tests/test_runner/test_discover_runner.py @@ -1,8 +1,22 @@ from contextlib import contextmanager import os +import sys from django.test import TestCase 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): @@ -35,6 +49,9 @@ class DiscoverRunnerTest(TestCase): 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): count = DiscoverRunner().build_suite( ["test_discovery_sample.tests_sample.TestVanillaUnittest.test_sample"],