當前位置: 首頁>>代碼示例>>Python>>正文


Python Root.setLastTest方法代碼示例

本文整理匯總了Python中WMCore.WebTools.Root.Root.setLastTest方法的典型用法代碼示例。如果您正苦於以下問題:Python Root.setLastTest方法的具體用法?Python Root.setLastTest怎麽用?Python Root.setLastTest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WMCore.WebTools.Root.Root的用法示例。


在下文中一共展示了Root.setLastTest方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: RESTBaseUnitTest

# 需要導入模塊: from WMCore.WebTools.Root import Root [as 別名]
# 或者: from WMCore.WebTools.Root.Root import setLastTest [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.setLastTest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。