From 29ca363a7c491fab611cb086167a2aef967ec13f Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Tue, 10 Sep 2019 19:22:28 +0300 Subject: [PATCH] PY-37841: Use official hook API to parse config instead of dirty hack. See Bruno's comment in issue. GitOrigin-RevId: af0c4bee1f415a2148e7a824630a949ba3db0051 --- python/helpers/pycharm/_jb_pytest_runner.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/python/helpers/pycharm/_jb_pytest_runner.py b/python/helpers/pycharm/_jb_pytest_runner.py index 258c2fe5ca1f..86b997624879 100644 --- a/python/helpers/pycharm/_jb_pytest_runner.py +++ b/python/helpers/pycharm/_jb_pytest_runner.py @@ -3,7 +3,6 @@ import sys import pytest from _pytest.config import get_plugin_manager -from _pytest import config from pkg_resources import iter_entry_points @@ -31,11 +30,13 @@ if __name__ == '__main__': args += ["-s"] jb_doc_args("pytest", args) - # We need to preparse numprocesses because user may set it using ini file - config_result = config._prepareconfig(args, plugins_to_load) - if getattr(config_result.option, "numprocesses", None): - set_parallel_mode() + class Plugin: + @staticmethod + def pytest_configure(config): + if getattr(config.option, "numprocesses", None): + set_parallel_mode() + start_protocol() - start_protocol() - pytest.main(args, plugins_to_load) + + pytest.main(args, plugins_to_load + [Plugin])