示例#1
0
文件: valid.py 项目: gburet/pytestemb
    def scan(cls):

        testclasses = cls.retrieve_test_class()

        if len(testclasses) == 0:
            return  # nothing to add
        elif len(testclasses) == 1:
            testclass = testclasses[0]
        else:
            raise pexception.PytestembError("Only one Test class supported")

        inst = testclass()
        setup, cases, cleanup = cls.retrieve_test_method(inst)

        if setup is None:
            pass
        else:
            func_setup = getattr(inst, setup)
            Valid.get().set_setup(func_setup)

        for func_name in cases:
            func_case = getattr(inst, func_name)
            Valid.get().add_test_case(func_case)

        if cleanup is None:
            pass
        else:
            func_cleanup = getattr(inst, cleanup)
            Valid.get().set_cleanup(func_cleanup)
示例#2
0
 def is_assert(self):
     try:
         return (self.result[-1][self.ASSERT_KO] > 0)
     except IndexError:
         raise pexception.PytestembError(
             "Invalid use of is_assert, allowed only in setup/cleanup and case"
         )
示例#3
0
文件: valid.py 项目: gburet/pytestemb
 def set_tracecase(self, functracecase):
     if self._tracecase == self._nothing_:
         self._tracecase = functracecase
     else:
         # Avoid user mistake with two time function set
         raise pexception.PytestembError(
             "functracecase function already set")
示例#4
0
文件: valid.py 项目: gburet/pytestemb
 def tracecase(self, name):
     if self._tracecase != self._nothing_:
         try:
             self._tracecase(utils.get_script_name(), name)
         except Exception, ex:
             raise pexception.PytestembError(
                 "Callback tracecase exception : '%s' => %s" %
                 (ex.__class__.__name__, ex))
示例#5
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")
示例#6
0
文件: valid.py 项目: gburet/pytestemb
 def set_destroy(self, funcdestroy):
     if self._destroy == self._nothing_:
         self._destroy = funcdestroy
     else:
         # Avoid user mistake with two time function set
         raise pexception.PytestembError("funcDestroy function already set")
示例#7
0
文件: valid.py 项目: gburet/pytestemb
 def set_create(self, funccreate):
     if self._create == self._nothing_:
         self._create = funccreate
     else:
         # Avoid user mistake with two time function set
         raise pexception.PytestembError("funcCreate function already set")
示例#8
0
文件: valid.py 项目: gburet/pytestemb
 def set_cleanup(self, funccleanup):
     if self._cleanup == self._nothing_:
         self._cleanup = funccleanup
     else:
         # Avoid user mistake with two time function set
         raise pexception.PytestembError("CleanUp function already set")