From b82eb6f22098da58e6138f5243f4d151b83aa9af Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Wed, 12 Jul 2017 23:21:15 +0300 Subject: [PATCH] PY-23926: Check teamcity plugin via setuptools api and do not add it if already registered. --- python/helpers/pycharm/_jb_pytest_runner.py | 6 +++--- python/setup-test-environment/build.gradle | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/helpers/pycharm/_jb_pytest_runner.py b/python/helpers/pycharm/_jb_pytest_runner.py index 61f657f356c7..cea20a89e61f 100644 --- a/python/helpers/pycharm/_jb_pytest_runner.py +++ b/python/helpers/pycharm/_jb_pytest_runner.py @@ -7,8 +7,7 @@ from _pytest.config import get_plugin_manager from _jb_runner_tools import jb_start_tests, jb_patch_separator, jb_doc_args, JB_DISABLE_BUFFERING from teamcity import pytest_plugin - - +from pkg_resources import iter_entry_points if __name__ == '__main__': path, targets, additional_args = jb_start_tests() @@ -22,7 +21,8 @@ if __name__ == '__main__': # to prevent "plugin already registered" problem we check it first plugins_to_load = [] if not get_plugin_manager().hasplugin("pytest-teamcity"): - plugins_to_load.append(pytest_plugin) + if "pytest-teamcity" not in map(lambda e:e.name, iter_entry_points(group='pytest11', name=None)): + plugins_to_load.append(pytest_plugin) args = sys.argv[1:] if JB_DISABLE_BUFFERING and "-s" not in args: diff --git a/python/setup-test-environment/build.gradle b/python/setup-test-environment/build.gradle index 9dfed8f2c777..398dae824960 100644 --- a/python/setup-test-environment/build.gradle +++ b/python/setup-test-environment/build.gradle @@ -12,7 +12,7 @@ envs { packages = ["pip", "setuptools"] _64Bits = true - conda "django19", "2.7", ["django==1.9", "tox", "nose", "pytest", "behave", "lettuce>=0.2.22", "unittest2"], true + conda "django19", "2.7", ["django==1.9", "tox", "nose", "pytest", "behave", "lettuce>=0.2.22", "unittest2", "teamcity-messages"], true textfile "django19/tags.txt", "python2.7\ndjango\nnose\npytest\nbehave\nlettuce\npackaging\ntox\nunittest2" conda "django110", "3.4", ["django==1.10", "django-nose"], false