Exemple #1
0
 def wrapper(actual_kallable):
     msg = "You are decorating {} in {} module with @skip by providing one or more arguments."
     msg += "Remove the arguments and proceed."
     Arjuna.get_console().display_error(msg.format(
             actual_kallable.__qualname__,
             actual_kallable.__module__
         ))
     sys_utils.fexit()
Exemple #2
0
 def __validate_state(self, kallable, dec_type):
     if self.__loading_completed:
         ktype = type(kallable) is type and "class" or "function"
         from arjuna.tpi import Arjuna
         Arjuna.get_console().display_error(
             "You are decorating inner {} {} with {} in {} module. These decorators are ignored by Arjuna.".format(
                 ktype,
                 kallable.__qualname__,
                 dec_type,
                 kallable.__module__
             ))
         return False
     return True
Exemple #3
0
 def __init__(self):
     self.files = []
     self.found_class_names = set()
     self.temp_map = {}
     from arjuna.tpi import Arjuna
     self.logger = Arjuna.get_logger()
     self.console = Arjuna.get_console()
Exemple #4
0
    def __init__(self):
        self.pkg = None
        self.module = None
        self.func = None
        self.qname = None

        self.__tvars = None
        self.__threads = None
        self.__deps = None
        self.__drefs = None
        self.__dsources = []
        self.__instances = []

        self.__skipped = False
        self.__skip_code = None
        self.selected = False
        self.__unpicked = True
        self.__unpick_code = None

        self.consumed = False

        from arjuna.tpi import Arjuna
        self.console = Arjuna.get_console()
        self.logger = Arjuna.get_logger()
        self.central_config = Arjuna.get_central_config()
Exemple #5
0
 def load_session(self, session_name):
     from arjuna.tpi import Arjuna
     from arjuna.unitee.test.defs.session import UserDefinedSessionDef
     sdir = Arjuna.get_central_config().get_arjuna_option_value(
         ArjunaOption.UNITEE_PROJECT_SESSIONS_DIR).as_str()
     session_file_path = os.path.join(sdir, session_name + ".xml")
     if not file_utils.is_file(session_file_path):
         Arjuna.get_console().display_error(
             "Not able to find session file {}.xml at {}".format(
                 session_name, sdir))
         sys_utils.fexit()
     sdef = UserDefinedSessionDef(session_name, session_file_path)
     sdef.process()
     self.__session = sdef.pick()
     self.__session.context = self.__create_test_context()
     self.__session.load()
Exemple #6
0
 def __init__(self, fpath, gname, rules_node):
     self.gname = gname
     self.fpath = fpath
     self.root = rules_node
     self.__rules = []
     from arjuna.tpi import Arjuna
     self.console = Arjuna.get_console()
     self.__process()
Exemple #7
0
 def __init__(self):
     self.lock = threading.RLock()
     self.__loading_completed = False
     self.__mlmap = {}
     from arjuna.tpi import Arjuna
     ref_config = Arjuna.get_ref_config()
     self.proj_dir = ref_config.get_arjuna_option_value(ArjunaOption.PROJECT_ROOT_DIR).as_str()
     self.test_dir = ref_config.get_arjuna_option_value(ArjunaOption.UNITEE_PROJECT_TESTS_DIR).as_str()
     self.logger = Arjuna.get_logger()
     self.console = Arjuna.get_console()
Exemple #8
0
 def __init__(self, pkg, module, qname):
     self.pkg = pkg
     self.module = module
     self.qname = qname
     from arjuna.tpi import Arjuna
     self.console = Arjuna.get_console()
     self.logger = Arjuna.get_logger()
     self.mdef = ModDef(pkg, module, qname)
     self._current_kall_ids = {}
     self._current_kall_decs = {}
     self.__multidecs = {}
     from arjuna.tpi import Arjuna
     self.unitee = Arjuna.get_unitee_instance()
Exemple #9
0
    def __init__(self, fpath, gname, pickers_node):
        self.gname = gname
        self.fpath = fpath
        self.root = pickers_node

        # Although using a set would give better performance, using a list so that pickers are evaluated
        # in the order they are specified.
        self._rule_dict = CIStringDict({
            'cm': [],
            'im': [],
            'cf': [],
            'if': []
        })

        self.__module_matcher = None
        self.__function_matcher = None

        from arjuna.tpi import Arjuna
        self.console = Arjuna.get_console()
        self.tm_prefix = Arjuna.get_central_config().get_arjuna_option_value(
            ArjunaOption.UNITEE_PROJECT_TEST_MODULE_IMPORT_PREFIX).as_str()
        self.__process()
Exemple #10
0
    def __load_user_gconfs(gconfs):
        from arjuna.tpi import Arjuna
        console = Arjuna.get_console()
        central_config = Arjuna.get_central_config()
        ugcdir = central_config.get_arjuna_option_value(ArjunaOption.CONFIG_DIR).as_str()
        ugfpath = os.path.join(ugcdir, "groups.xml")

        def display_err_and_exit(msg):
            console.display_error((msg + " Fix groups template file: {}").format(ugfpath))
            sys_utils.fexit()

        if not os.path.exists(ugfpath) or not os.path.isfile(ugfpath):
            return

        try:
            tree = ETree.parse(ugfpath)
        except Exception as e:
            print(e)
            display_err_and_exit("Groups definition file could not be loaded because of errors in XML.")
        else:
            root = tree.getroot()
            if root.tag != 'groups':
                display_err_and_exit("Invalid groups template file. Root element tag should be >>groups<<.")
            node_dict = etree_utils.convert_to_cidict(root)

            # Validate only group keys exist.
            if node_dict.keys() != {'group'}:
                display_err_and_exit(">>groups<< element can contain only one or more >>group<< elements.")
            elif not node_dict:
                display_err_and_exit(">>groups<< element must contain atleast one >>group<< element.")
            else:
                for group in list(root):
                    run_conf_utils.validate_group_xml_child("session", ugfpath, group)
                    group_attrs = etree_utils.convert_attribs_to_cidict(group)
                    name = group_attrs['name'].strip()
                    if not name:
                        display_err_and_exit(">>name<< attribute in group definition can not be empty.")
                    gconfs[name] = GroupConf(name, group, ugfpath)
Exemple #11
0
 def __init__(self):
     self.lock = threading.RLock()
     self.console = Arjuna.get_console()
Exemple #12
0
from .enums import TimeUnit

class Time:

    def __init__(self, time_unit, value):
        self.__unit = time_unit
        self.__value = value

    @staticmethod
    def seconds(self, secs):
        return Time(TimeUnit.SECONDS, secs)

    @staticmethod
    def milli_seconds(self, ms):
        return Time(TimeUnit.MILLI_SECONDS, ms)

    @staticmethod
    def minutes(self, mins):
        return Time(TimeUnit.MINUTES, mins)

from arjuna.tpi import Arjuna

logger = Arjuna.get_logger()
console = Arjuna.get_console()

Exemple #13
0
 def __init__(self):
     from arjuna.tpi import Arjuna
     self.logger = Arjuna.get_logger()
     self.console = Arjuna.get_console()
     self.central_config = Arjuna.get_central_config()
     self.unitee = Arjuna.get_unitee_instance()
Exemple #14
0
def cexit():
    from arjuna.tpi import Arjuna
    Arjuna.get_console().display_error("Exiting...")
    sys.exit()