当前位置: 首页>>代码示例>>Python>>正文


Python TestCase.checkState方法代码示例

本文整理汇总了Python中TestCase.TestCase.checkState方法的典型用法代码示例。如果您正苦于以下问题:Python TestCase.checkState方法的具体用法?Python TestCase.checkState怎么用?Python TestCase.checkState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestCase.TestCase的用法示例。


在下文中一共展示了TestCase.checkState方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from TestCase import TestCase [as 别名]
# 或者: from TestCase.TestCase import checkState [as 别名]
class RestartableRunner:
    """class for running a single configuration without writing out
    any results. Can be asked to restart stop and restart the EVB."""

    def __init__(self, testRunner):
        # @param testRunner is used to get the requested
        #        EVB configuration. It should inherit
        #        from class TestRunner and have a method
        #        getConfiguration()

        self.testRunner = testRunner

        # flag whether EVB should be restarted
        # after it was stopped or not
        self.stopFlag = False

        # flag for 'evb was started'
        self.evbStarted = threading.Event()
        self.evbStopped = threading.Event()
        self.evbStopped.set()

        # queues for communication with
        # callback which is called after
        # the startup of the EVB
        from Queue import Queue

        # used to signal that the EVB should be stopped
        self.stopQueue = Queue()

        # acknowledgement events that EVB was stopped
        self.stopAckQueue = Queue()

        # callback which is called after a TestCaseObject was created
        self.beforeScanStartCallback = None

        self.testCase = None



    def run(self, stdout):

        logging.info("RestartableRunner.run() called")

        self.testRunner.startLaunchers()

        # TODO: check if all launchers are responding (with timeout)
        # instead of waiting for a fixed amount of time
        time.sleep(5)

        configData = self.testRunner.getAllConfigurations()[0]
        config = configData['config']
        testName = configData['name']

        try:
            while not self.stopFlag:
                try:
                    self.testCase = TestCase(config, stdout, afterStartupCallback=self.afterStartupCallback)
                    self.testCase.prepare(testName)

                    fragSize = self.testRunner.getFedSizes()
                    assert len(fragSize) == 1

                    fragSize = fragSize[0]
                    fragSizeRMS = int(fragSize * self.testRunner.args['rms'])

                    # this should only terminate when the user terminates the optimization
                    self.testCase.runScan(fragSize, fragSizeRMS, self.testRunner.args)

                    # evb was stopped
                    self.evbStarted.clear()
                    self.evbStopped.set()

                    self.testCase.destroy()
                    self.testCase = None

                except BadConfig:
                    self.stopFlag = True
                    sys.exit(1)
        finally:
            self.testRunner.stopLaunchers()



    def checkApplicationsEnabled(self):
        # @return true if all applications are in 'Enabled' state
        # note that this gives only meaningful results
        # while run() is running

        if not self.testCase is None:
            try:
                self.testCase.checkState('Enabled')
                return True
            except (StateException, FailedState), ex:
                # some are not in Enabled state
                return False

        return None
开发者ID:andreh12,项目名称:evb,代码行数:99,代码来源:RestartableRunner.py


注:本文中的TestCase.TestCase.checkState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。