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


Python Root.getLastTest方法代码示例

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


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

示例1: RESTBaseUnitTest

# 需要导入模块: from WMCore.WebTools.Root import Root [as 别名]
# 或者: from WMCore.WebTools.Root.Root import getLastTest [as 别名]
class RESTBaseUnitTest(unittest.TestCase):

    def setUp(self, initRoot = True):
        # default set
        self.schemaModules = []

        self.initialize()
        if self.schemaModules:
            import warnings
            warnings.warn("use RESTAndCouchUnitTest instead", DeprecationWarning)
            from WMQuality.TestInitCouchApp import TestInitCouchApp
            self.testInit = TestInitCouchApp(__file__)
            self.testInit.setLogging() # logLevel = logging.SQLDEBUG
            self.testInit.setDatabaseConnection()
            self.testInit.setSchema(customModules = self.schemaModules,
                                    useDefault = False)
            # Now pull the dbURL from the factory
            # I prefer this method because the factory has better error handling
            # Also because then you know everything is the same
            myThread = threading.currentThread()
            self.config.setDBUrl(myThread.dbFactory.dburl)

        logging.info("This is our config: %s" % self.config)

        self.initRoot = initRoot
        if initRoot:
            self.rt = Root(self.config, testName=self._testMethodName)
            try:
                self.rt.start(blocking=False)
            except RuntimeError, e:
                # there appears to be worker threads from a previous test
                # hanging out. Try to slay them so that we can keep going
                print "Failed to load cherrypy with exception: %s\n" % e
                print "The threads are: \n%s\n" % threading.enumerate()
                print "The previous test was %s\n" % self.rt.getLastTest()
                print traceback.format_exc()
                self.rt.stop()
                raise e

        return
开发者ID:cinquo,项目名称:WMCore,代码行数:42,代码来源:RESTBaseUnitTest.py

示例2: RESTBaseUnitTest

# 需要导入模块: from WMCore.WebTools.Root import Root [as 别名]
# 或者: from WMCore.WebTools.Root.Root import getLastTest [as 别名]
class RESTBaseUnitTest(unittest.TestCase):

    def setUp(self, initRoot = True):
        # default set
        self.schemaModules = []

        self.initialize()
        if self.schemaModules:
            import warnings
            warnings.warn("use RESTAndCouchUnitTest instead", DeprecationWarning)
            from WMQuality.TestInitCouchApp import TestInitCouchApp
            self.testInit = TestInitCouchApp(__file__)
            self.testInit.setLogging() # logLevel = logging.SQLDEBUG
            self.testInit.setDatabaseConnection( destroyAllDatabase = True )
            self.testInit.setSchema(customModules = self.schemaModules,
                                    useDefault = False)
            # Now pull the dbURL from the factory
            # I prefer this method because the factory has better error handling
            # Also because then you know everything is the same
            myThread = threading.currentThread()
            self.config.setDBUrl(myThread.dbFactory.dburl)

        logging.info("This is our config: %s" % self.config)

        self.initRoot = initRoot
        if initRoot:
            self.rt = Root(self.config, testName=self._testMethodName)
            try:
                self.rt.start(blocking=False)
            except RuntimeError as e:
                # there appears to be worker threads from a previous test
                # hanging out. Try to slay them so that we can keep going
                print "Failed to load cherrypy with exception: %s\n" % e
                print "The threads are: \n%s\n" % threading.enumerate()
                print "The previous test was %s\n" % self.rt.getLastTest()
                print traceback.format_exc()
                self.rt.stop()
                raise e

        return

    def tearDown(self):
        if self.initRoot:
            self.rt.stop()
            self.rt.setLastTest()
            # there was a ton of racy failures in REST tools because of
            # how much global state cherrypy has. this resets it

            # Also, it sucks I had to copy/paste this from
            # https://bitbucket.org/cherrypy/cherrypy/src/9720342ad159/cherrypy/__init__.py
            # but reload() doesn't have the right semantics

            cherrybus.bus = cherrybus.Bus()
            cherrypy.engine = cherrybus.bus
            cherrypy.engine.timeout_monitor = cherrypy._TimeoutMonitor(cherrypy.engine)
            cherrypy.engine.timeout_monitor.subscribe()

            cherrypy.engine.autoreload = cherrypy.process.plugins.Autoreloader(cherrypy.engine)
            cherrypy.engine.autoreload.subscribe()

            cherrypy.engine.thread_manager = cherrypy.process.plugins.ThreadManager(cherrypy.engine)
            cherrypy.engine.thread_manager.subscribe()

            cherrypy.engine.signal_handler = cherrypy.process.plugins.SignalHandler(cherrypy.engine)
            cherrypy.engine.subscribe('log', cherrypy._buslog)

            from cherrypy import _cpserver
            cherrypy.server = _cpserver.Server()
            cherrypy.server.subscribe()
            cherrypy.checker = cherrypy._cpchecker.Checker()
            cherrypy.engine.subscribe('start', cherrypy.checker)

        if self.schemaModules:
            self.testInit.clearDatabase()
        self.config = None
        return

    def initialize(self):
        """
        i.e.

        self.config = DefaultConfig('WMCore.WebTools.RESTModel')
        self.config.setDBUrl('sqlite://')
        self.schemaModules = ['WMCore.ThreadPool', 'WMCore.WMBS']
        """

        message = "initialize method has to be implemented, self.restModel, self.schemaModules needs to be set"
        raise NotImplementedError, message
开发者ID:pietverwilligen,项目名称:WMCore,代码行数:90,代码来源:RESTBaseUnitTest.py


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