Nosetest runner recognized even if its subclass used (PY-8042)

This commit is contained in:
Ilya.Kazakevich
2015-06-15 19:55:25 +03:00
parent 7ecd4ff0a3
commit f79243f6db
+22 -4
View File
@@ -2,17 +2,35 @@ from tcunittest import TeamcityTestRunner, TeamcityTestResult
from tcmessages import TeamcityServiceMessages
import sys
from pycharm_run_utils import adjust_django_sys_path
from django.test.utils import get_runner
adjust_django_sys_path()
from django.conf import settings
if hasattr(settings, "TEST_RUNNER") and "NoseTestSuiteRunner" in settings.TEST_RUNNER:
from nose_utils import TeamcityNoseRunner
def _is_nosetest(settings):
"""
Checks if Django configured to work with nosetest
:param settings: django settings
:return: True if django should works with NoseTest runner of its inheritor
"""
try:
runner = get_runner(settings)
from django_nose import NoseTestSuiteRunner
if issubclass(runner, NoseTestSuiteRunner):
return True
except (AttributeError, ImportError):
pass
return False
from django.test.testcases import TestCase
from django import VERSION
if _is_nosetest(settings):
from nose_utils import TeamcityNoseRunner
# See: https://docs.djangoproject.com/en/1.8/releases/1.7/#django-utils-unittest
# django.utils.unittest provided uniform access to the unittest2 library on all Python versions.
# Since unittest2 became the standard library's unittest module in Python 2.7,
@@ -110,7 +128,7 @@ class DjangoTeamcityTestRunner(BaseRunner):
return suite
def run_suite(self, suite, **kwargs):
if hasattr(settings, "TEST_RUNNER") and "NoseTestSuiteRunner" in settings.TEST_RUNNER:
if _is_nosetest(settings):
from django_nose.plugin import DjangoSetUpPlugin, ResultPlugin
from django_nose.runner import _get_plugins_from_settings
from nose.config import Config
@@ -133,7 +151,7 @@ class DjangoTeamcityTestRunner(BaseRunner):
return TeamcityTestRunner.run(self, suite, **self.options)
def run_tests(self, test_labels, extra_tests=None, **kwargs):
if hasattr(settings, "TEST_RUNNER") and "NoseTestSuiteRunner" in settings.TEST_RUNNER:
if _is_nosetest(settings):
return super(DjangoTeamcityTestRunner, self).run_tests(test_labels, extra_tests)
return super(DjangoTeamcityTestRunner, self).run_tests(test_labels, extra_tests, **kwargs)