Beispiel #1
0
def jb_start_tests():
    """
    Parses arguments, starts protocol and returns tuple of arguments

    :return: (string with path or None, list of targets or None, list of additional arguments)
    :param func_to_parse function that accepts each part of test name and returns list to be used instead of it.
    It may return list with only one element (name itself) if name is the same or split names to several parts
    """

    # Handle additional args after --
    additional_args = []
    try:
        index = sys.argv.index("--")
        additional_args = sys.argv[index + 1:]
        del sys.argv[index:]
    except ValueError:
        pass
    utils = _jb_utils.VersionAgnosticUtils()

    namespace = utils.get_options(
        _jb_utils.OptionDescription('--path', 'Path to file or folder to run'),
        _jb_utils.OptionDescription('--target', 'Python target to run', "append"))
    del sys.argv[1:]  # Remove all args
    NewTeamcityServiceMessages().message('enteredTheMatrix')

    # Working dir should be on path, that is how runners work when launched from command line
    sys.path.insert(1, os.getcwd())
    return namespace.path, namespace.target, additional_args
def jb_start_tests():
    """
    Parses arguments, starts protocol and returns tuple of arguments

    :return: (string with path or None, list of targets or None, list of additional arguments)
    :param func_to_parse function that accepts each part of test name and returns list to be used instead of it.
    It may return list with only one element (name itself) if name is the same or split names to several parts
    """

    # Handle additional args after --
    additional_args = []
    try:
        index = sys.argv.index("--")
        additional_args = sys.argv[index + 1:]
        del sys.argv[index:]
    except ValueError:
        pass
    utils = _jb_utils.VersionAgnosticUtils()

    namespace = utils.get_options(
        _jb_utils.OptionDescription('--path', 'Path to file or folder to run'),
        _jb_utils.OptionDescription('--target', 'Python target to run',
                                    "append"))
    del sys.argv[1:]  # Remove all args
    NewTeamcityServiceMessages().message('enteredTheMatrix')

    # PyCharm helpers dir is first dir in sys.path because helper is launched.
    # But sys.path should be same as when launched with test runner directly
    try:
        if os.path.abspath(sys.path[0]) == os.path.abspath(
                os.environ["PYCHARM_HELPERS_DIR"]):
            sys.path.pop(0)
    except KeyError:
        pass
    return namespace.path, namespace.target, additional_args
Beispiel #3
0
def parse_arguments():
    """
    Parses arguments, fixes syspath and returns tuple of arguments

    :return: (string with path or None, list of targets or None, list of additional arguments)
    It may return list with only one element (name itself) if name is the same or split names to several parts
    """
    # Handle additional args after --
    additional_args = []
    try:
        index = sys.argv.index("--")
        additional_args = sys.argv[index + 1:]
        del sys.argv[index:]
    except ValueError:
        pass
    utils = _jb_utils.VersionAgnosticUtils()
    namespace = utils.get_options(
        _jb_utils.OptionDescription('--path', 'Path to file or folder to run'),
        _jb_utils.OptionDescription('--offset', 'Root node offset'),
        _jb_utils.OptionDescription('--target', 'Python target to run', "append"))
    del sys.argv[1:]  # Remove all args

    # PyCharm helpers dir is first dir in sys.path because helper is launched.
    # But sys.path should be same as when launched with test runner directly
    try:
        if os.path.abspath(sys.path[0]) == os.path.abspath(os.environ["PYCHARM_HELPERS_DIR"]):
            sys.path.pop(0)
    except KeyError:
        pass
    _TREE_MANAGER_HOLDER.offset = int(namespace.offset if namespace.offset else 0)
    return namespace.path, namespace.target, additional_args