From 393fe4bd0bc0dbc647dbe42d412dd66da91528c8 Mon Sep 17 00:00:00 2001 From: Ekaterina Tuzova Date: Mon, 10 Feb 2014 12:41:15 +0400 Subject: [PATCH] proper fix for PY-12052 Can't run django tests with nosetests because of `nose_utils` not found. --- python/helpers/pycharm/django_test_runner.py | 4 +++- python/helpers/pycharm/pycharm_run_utils.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/python/helpers/pycharm/django_test_runner.py b/python/helpers/pycharm/django_test_runner.py index d2efc2c79610..f3f20a0717a8 100644 --- a/python/helpers/pycharm/django_test_runner.py +++ b/python/helpers/pycharm/django_test_runner.py @@ -2,12 +2,14 @@ from tcunittest import TeamcityTestRunner, TeamcityTestResult from tcmessages import TeamcityServiceMessages import sys from pycharm_run_utils import adjust_django_sys_path -from nose_utils import TeamcityNoseRunner 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 + from django.test.testcases import TestCase from django import VERSION try: diff --git a/python/helpers/pycharm/pycharm_run_utils.py b/python/helpers/pycharm/pycharm_run_utils.py index 5fbc35cc1582..d905d0542303 100644 --- a/python/helpers/pycharm/pycharm_run_utils.py +++ b/python/helpers/pycharm/pycharm_run_utils.py @@ -20,9 +20,10 @@ def adjust_sys_path(add_script_parent=True, script_index=1): insert_to_sys_path(script_path) def adjust_django_sys_path(): - sys.path.pop(0) + pycharm_path = sys.path.pop(0) script_path = sys.argv[-1] insert_to_sys_path(script_path) + sys.path.append(pycharm_path) def import_system_module(name): f, filename, desc = imp.find_module(name)