• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tests.B3TestCase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.B3TestCase的典型用法代码示例。如果您正苦于以下问题:Python B3TestCase类的具体用法?Python B3TestCase怎么用?Python B3TestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: setUp

 def setUp(self):
     B3TestCase.setUp(self)
     self.conf = XmlConfigParser()
     self.conf.load(ADMIN_CONFIG_FILE)
     self.p = AdminPlugin(self.console, self.conf)
     self.p.onLoadConfig()
     self.p.onStartup()
开发者ID:ozon,项目名称:big-brother-bot,代码行数:7,代码来源:test_admin.py


示例2: setUp

 def setUp(self):
     """this method is called before each test"""
     B3TestCase.setUp(self)
     try:
         conn = psycopg2.connect(host='localhost', user='b3test', password='test', database='postgres')
     except psycopg2.OperationalError, message:
         self.fail("Error %d:\n%s" % (message[0], message[1]))
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:7,代码来源:test_postgresql.py


示例3: setUp

    def setUp(self):
        """
        This method is called before each test.
        It is meant to set up the SUT (System Under Test) in a manner that will ease the testing of its features.
        """
        with logging_disabled():
            # The B3TestCase class provides us a working B3 environment that does not require any database connexion.
            # The B3 console is then accessible with self.console
            B3TestCase.setUp(self)

            # set additional B3 console stuff that will be used by the XLRstats plugin
            self.console.gameName = "MyGame"
            self.parser_conf.add_section('b3')
            self.parser_conf.set('b3', 'time_zone', 'GMT')

            # we make our own AdminPlugin and make sure it is the one return in any case
            self.adminPlugin = AdminPlugin(self.console, DEFAULT_ADMIN_CONFIG_FILE)
            when(self.console).getPlugin("admin").thenReturn(self.adminPlugin)
            self.adminPlugin.onLoadConfig()
            self.adminPlugin.onStartup()

            # We need a config for the Xlrstats plugin
            self.conf = CfgConfigParser()  # It is an empty config but we can fill it up later

            # Now we create an instance of the SUT (System Under Test) which is the XlrstatsPlugin
            self.p = XlrstatsPlugin(self.console, self.conf)
            when(self.console).getPlugin("xlrstats").thenReturn(self.p)

            # create a client object to represent the game server
            with patch("b3.clients.Clients.authorizeClients"):  # we patch authorizeClients or it will spawn a thread
                # with a 5 second timer
                self.console.clients.newClient(-1, name="WORLD", guid="WORLD", hide=True)
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:32,代码来源:test_xlrstats.py


示例4: setUp

    def setUp(self):
        B3TestCase.setUp(self)
        when(self.console.config).get_external_plugins_dir().thenReturn(external_plugins_dir)
        self.conf = CfgConfigParser(testplugin_config_file)

        self.plugin_list = [
            {'name': 'admin', 'conf': '@b3/conf/plugin_admin.ini', 'path': None, 'disabled': False},
        ]

        fp, pathname, description = imp.find_module('testplugin1', [os.path.join(b3.getB3Path(True), '..', 'tests', 'plugins', 'fakeplugins')])
        pluginModule1 = imp.load_module('testplugin1', fp, pathname, description)
        if fp:
            fp.close()

        fp, pathname, description = imp.find_module('testplugin3', [os.path.join(b3.getB3Path(True), '..', 'tests', 'plugins', 'fakeplugins')])
        pluginModule3 = imp.load_module('testplugin3', fp, pathname, description)
        if fp:
            fp.close()

        fp, pathname, description = imp.find_module('admin', [os.path.join(b3.getB3Path(True), 'plugins')])
        adminModule = imp.load_module('admin', fp, pathname, description)
        if fp:
            fp.close()

        when(self.console.config).get_plugins().thenReturn(self.plugin_list)
        when(self.console).pluginImport('admin', ANY).thenReturn(adminModule)
        when(self.console).pluginImport('testplugin1', ANY).thenReturn(pluginModule1)
        when(self.console).pluginImport('testplugin3', ANY).thenReturn(pluginModule3)
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:28,代码来源:test_plugin.py


示例5: setUp

    def setUp(self):
        B3TestCase.setUp(self)

        with logging_disabled():
            admin_conf = CfgConfigParser()
            admin_plugin = AdminPlugin(self.console, admin_conf)
            admin_plugin.onLoadConfig()
            admin_plugin.onStartup()
            when(self.console).getPlugin('admin').thenReturn(admin_plugin)

        conf = CfgConfigParser()
        conf.loadFromString(dedent(r"""
            [commands]
            mapstats-stats: 0
            testscore-ts: 0
            topstats-top: 0
            topxp: 0

            [settings]
            startPoints: 100
            resetscore: no
            resetxp: no
            show_awards: no
            show_awards_xp: no
        """))
        self.p = StatsPlugin(self.console, conf)
        self.p.onLoadConfig()
        self.p.onStartup()

        self.joe = FakeClient(self.console, name="Joe", guid="joeguid", groupBits=1, team=TEAM_RED)
        self.mike = FakeClient(self.console, name="Mike", guid="mikeguid", groupBits=1, team=TEAM_RED)
        self.joe.connects(1)
        self.mike.connects(2)
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:33,代码来源:__init__.py


示例6: setUp

 def setUp(self):
     """this method is called before each test"""
     B3TestCase.setUp(self)
     try:
         db = MySQLdb.connect(host='localhost', user='b3test', passwd='test')
     except MySQLdb.OperationalError, message:
         self.fail("Error %d:\n%s" % (message[0], message[1]))
开发者ID:derfull,项目名称:big-brother-bot,代码行数:7,代码来源:test_mysql.py


示例7: setUp

 def setUp(self):
     """this method is called before each test"""
     B3TestCase.setUp(self)
     try:
         db = MySQLdb.connect(host=MYSQL_HOST, user=MYSQL_USER, passwd=MYSQL_PASSWORD)
     except MySQLdb.OperationalError, message:
         self.fail("Error %d:\n%s" % (message[0], message[1]))
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:7,代码来源:test_mysql.py


示例8: setUp

 def setUp(self):
     logger = logging.getLogger('output')
     logger.propagate = False
     B3TestCase.setUp(self)
     self.pb = PunkBuster(self.console)
     logger.setLevel(VERBOSE2)
     logger.propagate = True
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:7,代码来源:test_punkbuster.py


示例9: setUp

    def setUp(self):

        B3TestCase.setUp(self)
        self.console.gameName = 'f00'

        self.adminPlugin = AdminPlugin(self.console, '@b3/conf/plugin_admin.ini')
        when(self.console).getPlugin("admin").thenReturn(self.adminPlugin)
        self.adminPlugin.onLoadConfig()
        self.adminPlugin.onStartup()

        self.conf = CfgConfigParser()
        self.conf.loadFromString(dedent(r"""
            [settings]
            update_config_file: no

            [commands]
            cmdlevel: fulladmin
            cmdalias: fulladmin
            cmdgrant: superadmin
            cmdrevoke: superadmin
            cmduse: superadmin
        """))

        self.p = CmdmanagerPlugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:26,代码来源:__init__.py


示例10: setUp

 def setUp(self):
     B3TestCase.setUp(self)
     self.conf = XmlConfigParser()
     self.conf.setXml("""
         <configuration plugin="admin">
         </configuration>
     """)
     self.p = AdminPlugin(b3.console, self.conf)
开发者ID:Classixz,项目名称:b3bot-codwar,代码行数:8,代码来源:test_admin.py


示例11: setUp

 def setUp(self):
     B3TestCase.setUp(self)
     self.queueEvent_patcher = patch.object(self.console, 'queueEvent')
     self.queueEvent_mock = self.queueEvent_patcher.start()
     
     self.admin = Client(console=self.console)
     self.client = Client(console=self.console)
     self.client.save()
开发者ID:HaoDrang,项目名称:big-brother-bot,代码行数:8,代码来源:test_Client.py


示例12: setUp

    def setUp(self):
        B3TestCase.setUp(self)
        self.conf = XmlConfigParser()
        self.conf.load(ADMIN_CONFIG_FILE)
        self.p = AdminPlugin(self.console, self.conf)
        self.p.onLoadConfig()
        self.p.onStartup()

        self.joe = FakeClient(self.console, name="Joe", exactName="Joe", guid="joeguid", groupBits=128, team=TEAM_RED)
        self.mike = FakeClient(self.console, name="Mike", exactName="Mike", guid="mikeguid", groupBits=1, team=TEAM_BLUE)
开发者ID:ozon,项目名称:big-brother-bot,代码行数:10,代码来源:test_admin_functional.py


示例13: setUp

    def setUp(self):
        self.timer_patcher = patch('threading.Timer')
        self.timer_patcher.start()

        self.log = logging.getLogger('output')
        self.log.propagate = False

        B3TestCase.setUp(self)
        self.console.startup()
        self.log.propagate = True
开发者ID:ghostmod,项目名称:big-brother-bot,代码行数:10,代码来源:test_spamcontrol.py


示例14: setUp

 def setUp(self):
     B3TestCase.setUp(self)
     self.conf = XmlConfigParser()
     self.conf.setXml("""
         <configuration plugin="test">
             <settings name="settings">
                 <set name="output_file">@conf/status.xml</set>
             </settings>
         </configuration>
     """)
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:10,代码来源:test_config.py


示例15: setUp

    def setUp(self):
        B3TestCase.setUp(self)
        with logging_disabled():
            self.console.startup()

        logging.getLogger('output').setLevel(logging.DEBUG)

        self.conf = CfgConfigParser()
        self.p = ChatloggerPlugin(self.console, self.conf)

        when(self.console.config).get('b3', 'time_zone').thenReturn('GMT')
        self.p.setup_fileLogger = Mock()
开发者ID:deconevidya,项目名称:b3-plugin-chatlogger,代码行数:12,代码来源:test_config.py


示例16: setUp

    def setUp(self):
        self.log = logging.getLogger('output')
        self.log.propagate = False

        B3TestCase.setUp(self)

        self.adminPlugin = AdminPlugin(self.console, ADMIN_CONFIG)
        when(self.console).getPlugin("admin").thenReturn(self.adminPlugin)
        self.adminPlugin.onLoadConfig()
        self.adminPlugin.onStartup()

        self.console.startup()
        self.log.propagate = True
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:13,代码来源:test_adv.py


示例17: setUp

    def setUp(self):
        self.log = logging.getLogger('output')
        self.log.propagate = False

        B3TestCase.setUp(self)
        self.console.startup()
        self.log.propagate = True
        self.log.setLevel(logging.DEBUG)

        self.conf = XmlConfigParser()
        self.p = ChatloggerPlugin(self.console, self.conf)

        when(self.console.config).get('b3', 'time_zone').thenReturn('GMT')
        when(b3).getB3Path().thenReturn("c:\\b3_folder")
        when(b3).getConfPath().thenReturn("c:\\b3_conf_folder")
        self.p.setup_fileLogger = Mock()
开发者ID:82ndab-Bravo17,项目名称:b3-plugin-chatlogger,代码行数:16,代码来源:test_config.py


示例18: setUp

    def setUp(self):
        """this method is called before each test"""
        B3TestCase.setUp(self)

        try:
            dsn = "postgresql://%s:%[email protected]%s/%s" % (POSTGRESQL_TEST_USER, POSTGRESQL_TEST_PASSWORD, POSTGRESQL_TEST_HOST, POSTGRESQL_TEST_DB)
            self.storage = self.console.storage = PostgresqlStorage(dsn, splitDSN(dsn), self.console)
            self.storage.connect()

            tables = self.storage.getTables()
            if tables:
                # dont remove the groups table since we would need it in next tests
                tables.remove('groups')
                self.storage.truncateTable(tables)
        except Exception, e:
            self.fail("Error: %s" % e)
开发者ID:82ndab-Bravo17,项目名称:big-brother-bot,代码行数:16,代码来源:test_postgresql.py


示例19: setUp

    def setUp(self):
        self.log = logging.getLogger('output')
        self.log.propagate = False

        B3TestCase.setUp(self)

        admin_conf = XmlConfigParser()
        admin_conf.load(ADMIN_CONFIG_FILE)
        self.adminPlugin = AdminPlugin(self.console, admin_conf)
        when(self.console).getPlugin("admin").thenReturn(self.adminPlugin)
        self.adminPlugin.onLoadConfig()
        self.adminPlugin.onStartup()

        self.console.gameName = "theGame"
        self.console.startup()
        self.log.propagate = True
开发者ID:BradyBrenot,项目名称:big-brother-bot,代码行数:16,代码来源:test_login.py


示例20: setUp

    def setUp(self):
        B3TestCase.setUp(self)
        logging.getLogger('output').setLevel(logging.DEBUG)
        with logging_disabled():
            self.console.startup()
            self.conf = CfgConfigParser()
            self.p = ChatloggerPlugin(self.console, self.conf)

        ## prepare the mysql test database
        db = MySQLdb.connect(host=MYSQL_TEST_HOST, user=MYSQL_TEST_USER, passwd=MYSQL_TEST_PASSWORD)
        db.query("DROP DATABASE IF EXISTS %s" % MYSQL_TEST_DB)
        db.query("CREATE DATABASE %s CHARACTER SET utf8;" % MYSQL_TEST_DB)

        self.console.storage = DatabaseStorage(
            'mysql://%s:%[email protected]%s/%s' % (MYSQL_TEST_USER, MYSQL_TEST_PASSWORD, MYSQL_TEST_HOST, MYSQL_TEST_DB), self.console)
        self.console.storage.executeSql("@b3/sql/b3.sql")
        self.console.storage.executeSql(CHATLOGGER_SQL_FILE)

        when(self.console.config).get('b3', 'time_zone').thenReturn('GMT')
        self.p.setup_fileLogger = Mock()

        self.conf.loadFromString(dedent("""
            [general]
            save_to_database: Yes
            save_to_file: no

            [file]
            logfile: @conf/chat.log
            rotation_rate: D

            [purge]
            max_age: 0
            hour: 0
            min: 0
        """))
        with logging_disabled():
            self.p.onLoadConfig()
            self.p.onStartup()
            self.joe = FakeClient(self.console, name="Joe", guid="joe_guid", team=TEAM_RED)
            self.simon = FakeClient(self.console, name="Simon", guid="simon_guid", team=TEAM_BLUE)
            self.joe.connects(1)
            self.simon.connects(3)

        self.assertEqual(0, self.count_chatlog_lines())
        self.assertEqual(0, self.count_cmdlog_lines())
开发者ID:ChrisNolan1992,项目名称:b3-plugin-chatlogger,代码行数:45,代码来源:test_mysql.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tests.Bf3TestCase类代码示例发布时间:2022-05-27
下一篇:
Python tests.user_set函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap