From e782c57d74000722f9db4c9426317410520670c6 Mon Sep 17 00:00:00 2001 From: Tor Norbye Date: Thu, 18 Sep 2014 11:43:07 -0700 Subject: Snapshot idea/138.2210 from git://git.jetbrains.org/idea/community.git Change-Id: I8f0204d7887ee78cf1fd8c09f936c5afff0edd2f --- python/helpers/pycharm/_bdd_utils.py | 37 ++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'python/helpers/pycharm/_bdd_utils.py') diff --git a/python/helpers/pycharm/_bdd_utils.py b/python/helpers/pycharm/_bdd_utils.py index eea1bebf1654..65d0f93102b9 100644 --- a/python/helpers/pycharm/_bdd_utils.py +++ b/python/helpers/pycharm/_bdd_utils.py @@ -3,7 +3,7 @@ Tools for running BDD frameworks in python. You probably need to extend BddRunner (see its doc). -You may also need "get_path_by_args" that gets folder (current or passed as first argument) +You may also need "get_what_to_run_by_env" that gets folder (current or passed as first argument) """ import os import time @@ -29,20 +29,33 @@ def fix_win_drive(feature_path): os.chdir(feature_disk) -def get_path_by_args(arguments): +def get_what_to_run_by_env(environment): """ - :type arguments list - :param arguments: arguments (sys.argv) - :return: tuple (base_dir, what_to_run) where dir is current or first argument from argv, checking it exists - :rtype tuple of str + :type environment dict + :param environment: os.environment (files and folders should be separated with | and passed to PY_STUFF_TO_RUN). + Scenarios optionally could be passed as SCENARIOS (names or order numbers, depends on runner) + :return: tuple (base_dir, scenarios[], what_to_run(list of feature files or folders))) where dir is current or first argument from env, checking it exists + :rtype tuple of (str, iterable) """ - what_to_run = arguments[1] if len(arguments) > 1 else "." - base_dir = what_to_run - assert os.path.exists(what_to_run), "{} does not exist".format(what_to_run) + if "PY_STUFF_TO_RUN" not in environment: + what_to_run = ["."] + else: + what_to_run = str(environment["PY_STUFF_TO_RUN"]).split("|") - if os.path.isfile(what_to_run): - base_dir = os.path.dirname(what_to_run) # User may point to the file directly - return base_dir, what_to_run + scenarios = [] + if "SCENARIOS" in environment: + scenarios = str(environment["SCENARIOS"]).split("|") + + if not what_to_run: + what_to_run = ["."] + + for path in what_to_run: + assert os.path.exists(path), "{} does not exist".format(path) + + base_dir = what_to_run[0] + if os.path.isfile(what_to_run[0]): + base_dir = os.path.dirname(what_to_run[0]) # User may point to the file directly + return base_dir, scenarios, what_to_run class BddRunner(object): -- cgit v1.2.3