Beispiel #1
0
def register_name_globally(name: str, obj):
    if name in get_all()['_global_name_dict'] and not id(obj) == id(
            get_all()['_global_name_dict'][name]) and obj.allow_duplicate_name is False and \
            get_all()['_global_name_dict'][
                name].allow_duplicate_name is False and GlobalConfig().DEFAULT_TURN_OFF_GLOBAL_NAME_FLAG is False:
        raise GlobalNameExistedError(
            'name : {} is existed with object: {}'.format(name, get_all()['_global_name_dict'][name]))
    else:
        get_all()['_global_name_dict'][name] = obj
Beispiel #2
0
 def _save_all_obj_final_status(self):
     final_status = dict()
     for obj_name, obj in get_all()['_global_name_dict'].items():
         if hasattr(obj, 'get_status') and callable(
                 getattr(obj, 'get_status')):
             tmp_dict = dict()
             tmp_dict[obj_name] = dict()
             for st in obj.STATUS_LIST:
                 obj.set_status(st)
                 tmp_dict[obj_name][st] = obj.get_status()
             final_status = {**final_status, **tmp_dict}
     ConsoleLogger().print(
         'info', 'save final_status into {}'.format(
             os.path.join(self._record_file_log_dir)))
     self.out_to_file(file_path=os.path.join(self._record_file_log_dir),
                      content=final_status,
                      force_new=True,
                      file_name='final_status.json')
     ConsoleLogger().print(
         'info', 'save global_config into {}'.format(
             os.path.join(self._record_file_log_dir)))
     self.out_to_file(file_path=os.path.join(self._record_file_log_dir),
                      content=GlobalConfig().return_all_as_dict(),
                      force_new=True,
                      file_name='global_config.json')
Beispiel #3
0
def get_global_arg_dict():
    return get_all()['_global_obj_arg_dict']
Beispiel #4
0
 def wrap_with_self(self, *args, **kwargs):
     get_all()['_global_obj_arg_dict'][self] = dict(args=args,
                                                    kwargs=kwargs,
                                                    cls=type(self))
     res = fn(self, *args, **kwargs)
     return res
Beispiel #5
0
 def setUp(self):
     reset_all()
     reset_global_status_collect()
     for key, val in get_all().items():
         self.assertTrue(len(val) == 0)