Exemplo n.º 1
0
    def get_assert_caller(call_depth):

        DEFAULT = dict.fromkeys(["path", "line", "function", "code"], "no info")
        traceback = inspect.stack()
        dic = {}
        stack = []

        dic["file"]         = traceback[call_depth][1]
        dic["line"]         = traceback[call_depth][2]
        dic["function"]     = traceback[call_depth][3]
        dic["expression"]   = utils.to_unicode(traceback[call_depth][4][0]).strip(" \t\n\r")
        
        try:
            for index in range(call_depth+1, len(traceback)):
                if          traceback[index][1].endswith("valid.py") \
                    and     (traceback[index][3] == "run_case" or traceback[index][3] == "run_try" or traceback[index][3] == "run_abort") :
                    break
                stack.append(dict(DEFAULT))
                stack[-1]["path"]      = traceback[index][1]
                stack[-1]["line"]      = traceback[index][2]
                stack[-1]["function"]  = traceback[index][3]
                stack[-1]["code"]      = utils.to_unicode(traceback[index][4][0]).strip("\n\r")
        except Exception:
            pass 
            
        stack.reverse()
        return dic, stack
Exemplo n.º 2
0
    def get_assert_caller(call_depth):

        DEFAULT = dict.fromkeys(["path", "line", "function", "code"],
                                "no info")
        traceback = inspect.stack()
        dic = {}
        stack = []

        dic["file"] = traceback[call_depth][1]
        dic["line"] = traceback[call_depth][2]
        dic["function"] = traceback[call_depth][3]
        dic["expression"] = utils.to_unicode(
            traceback[call_depth][4][0]).strip(" \t\n")

        try:
            for index in range(call_depth + 1, len(traceback)):
                if          traceback[index][1].endswith("valid.py") \
                    and     (traceback[index][3] == "run_case" or traceback[index][3] == "run_try" or traceback[index][3] == "run_abort") :
                    break
                stack.append(dict(DEFAULT))
                stack[-1]["path"] = traceback[index][1]
                stack[-1]["line"] = traceback[index][2]
                stack[-1]["function"] = traceback[index][3]
                stack[-1]["code"] = utils.to_unicode(
                    traceback[index][4][0]).strip("\n")
        except Exception:
            pass

        stack.reverse()
        return dic, stack
Exemplo n.º 3
0
def trace_layer(scope, data):
    """
    @function       : trace_layer(scope, data)
    @param scope    : (string) string that refer the scope
    @param data     : (string) string to trace
    @return         : None
    @summary        : trace data towards layer trace type
    """
    trace.TraceManager.get().trace_layer(utils.to_unicode(scope), utils.to_unicode(data))
Exemplo n.º 4
0
def trace_io(interface, data):
    """
    @function       : trace_io(interface, data)
    @param interface: (string) string that refer the interface
    @param data     : (string) string to trace
    @return         : None
    @summary        : trace data towards io trace type
    """
    trace.TraceManager.get().trace_io(utils.to_unicode(interface), utils.to_unicode(data))
Exemplo n.º 5
0
def tag_value(tag, value):
    """
    @function       : tag_value(tag, value):
    @param tag      : (string) tag 
    @param value    : (string) value
    @return         : None
    @summary        : generate a tag value
    """
    result.Result.get().tag_value({utils.to_unicode(tag):utils.to_unicode(value)})
Exemplo n.º 6
0
 def trace_trace(self, dic_des):
     if isinstance(dic_des, dict):
         self._trace_trace_({
             utils.to_unicode(key): utils.to_unicode(value)
             for key, value in dic_des.iteritems()
         })
     else:
         raise pexception.PytestembError(
             "Parameter 'dic_des' must be a dict")
Exemplo n.º 7
0
def tag_value(tag, value):
    """
    @function       : tag_value(tag, value):
    @param tag      : (string) tag 
    @param value    : (string) value
    @return         : None
    @summary        : generate a tag value
    """
    result.Result.get().tag_value(
        {utils.to_unicode(tag): utils.to_unicode(value)})
Exemplo n.º 8
0
def trace_io(interface, data):
    """
    @function       : trace_io(interface, data)
    @param interface: (string) string that refer the interface
    @param data     : (string) string to trace
    @return         : None
    @summary        : trace data towards io trace type
    """
    trace.TraceManager.get().trace_io(utils.to_unicode(interface),
                                      utils.to_unicode(data))
Exemplo n.º 9
0
def trace_layer(scope, data):
    """
    @function       : trace_layer(scope, data)
    @param scope    : (string) string that refer the scope
    @param data     : (string) string to trace
    @return         : None
    @summary        : trace data towards layer trace type
    """
    trace.TraceManager.get().trace_layer(utils.to_unicode(scope),
                                         utils.to_unicode(data))
Exemplo n.º 10
0
def trace_script(msg):
    """
    @function       : trace_script(msg)
    @param msg      : (string) message to trace
    @return         : None
    @summary        : trace message, for script application
    """
    trace.TraceManager.get().trace_script(utils.to_unicode(msg))
Exemplo n.º 11
0
def trace_script(msg):
    """
    @function       : trace_script(msg)
    @param msg      : (string) message to trace
    @return         : None
    @summary        : trace message, for script application
    """
    trace.TraceManager.get().trace_script(utils.to_unicode(msg))
Exemplo n.º 12
0
    def inspect_traceback(self, exception):
        CALL_DEPTH = 1
        DEFAULT = dict.fromkeys(["path", "line", "function", "code"], "no info")
        traceback = inspect.trace()
        stack = []
        

        try :
            for index in range(CALL_DEPTH, len(traceback)):
                stack.append(dict(DEFAULT))
                stack[-1]["path"]      = traceback[index][1]
                stack[-1]["line"]      = traceback[index][2]
                stack[-1]["function"]  = traceback[index][3]
                stack[-1]["code"]      = utils.to_unicode(traceback[index][4][0]).strip("\n\r")
        except Exception:
            pass

        des = {}
        des["stack"]            = stack
        des["exception_info"]   = utils.to_unicode(exception)
        des["exception_class"]  = exception.__class__.__name__

        self._result.py_exception(des)
Exemplo n.º 13
0
    def inspect_traceback(self, exception):
        CALL_DEPTH = 1
        DEFAULT = dict.fromkeys(["path", "line", "function", "code"],
                                "no info")
        traceback = inspect.trace()
        stack = []

        try:
            for index in range(CALL_DEPTH, len(traceback)):
                stack.append(dict(DEFAULT))
                stack[-1]["path"] = traceback[index][1]
                stack[-1]["line"] = traceback[index][2]
                stack[-1]["function"] = traceback[index][3]
                stack[-1]["code"] = utils.to_unicode(
                    traceback[index][4][0]).strip("\n")
        except Exception:
            pass

        des = {}
        des["stack"] = stack
        des["exception_info"] = utils.to_unicode(exception)
        des["exception_class"] = exception.__class__.__name__

        self._result.py_exception(des)
Exemplo n.º 14
0
 def assert_notequal_fatal(self, exp1, exp2, des):
     values = "%s == %s" % (utils.to_unicode(exp1), utils.to_unicode(exp2))
     self._assert_((exp1 != exp2), True, des, values)
Exemplo n.º 15
0
 def trace_trace(self, dic_des):
     if isinstance(dic_des, dict):
         self._trace_trace_({utils.to_unicode(key):utils.to_unicode(value) for key, value in dic_des.iteritems()})
     else:
         raise pexception.PytestembError("Parameter 'dic_des' must be a dict")           
Exemplo n.º 16
0
 def assert_false_fatal(self, exp, des):
     values = "%s" % utils.to_unicode(exp)
     self._assert_(not(exp), True, des, values)
Exemplo n.º 17
0
 def assert_equal(self, exp1, exp2, des):
     values = "%s != %s" % (utils.to_unicode(exp1), utils.to_unicode(exp2))
     self._assert_((exp1 == exp2), False, des, values)
Exemplo n.º 18
0
 def assert_true(self, exp, des):
     values = "%s" % utils.to_unicode(exp)
     self._assert_(exp, False, des, values)
Exemplo n.º 19
0
 def assert_true(self, exp, des):
     values = "%s" % utils.to_unicode(exp)
     self._assert_(exp, False, des, values)
Exemplo n.º 20
0
 def assert_false_fatal(self, exp, des):
     values = "%s" % utils.to_unicode(exp)
     self._assert_(not (exp), True, des, values)
Exemplo n.º 21
0
 def assert_equal(self, exp1, exp2, des):
     values = "%s != %s" % (utils.to_unicode(exp1), utils.to_unicode(exp2))
     self._assert_((exp1 == exp2), False, des, values)
Exemplo n.º 22
0
 def assert_notequal_fatal(self, exp1, exp2, des):
     values = "%s == %s" % (utils.to_unicode(exp1), utils.to_unicode(exp2))
     self._assert_((exp1 != exp2), True, des, values)
Exemplo n.º 23
0
def _create_des_(msg):
    if msg is None :
        return {}
    else:
        return dict({"msg":utils.to_unicode(msg)})
Exemplo n.º 24
0
def _create_des_(msg):
    if msg is None:
        return {}
    else:
        return dict({u"msg": utils.to_unicode(msg)})