summaryrefslogtreecommitdiff
path: root/python/helpers/pycharm/_bdd_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/helpers/pycharm/_bdd_utils.py')
-rw-r--r--python/helpers/pycharm/_bdd_utils.py37
1 files changed, 25 insertions, 12 deletions
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):