本文整理汇总了Python中tests.B3TestCase.setUp方法的典型用法代码示例。如果您正苦于以下问题:Python B3TestCase.setUp方法的具体用法?Python B3TestCase.setUp怎么用?Python B3TestCase.setUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.B3TestCase
的用法示例。
在下文中一共展示了B3TestCase.setUp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
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()
示例2: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
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]))
示例3: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
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)
示例4: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
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)
示例5: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
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)
示例6: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
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]))
示例7: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
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]))
示例8: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
def setUp(self):
logger = logging.getLogger('output')
logger.propagate = False
B3TestCase.setUp(self)
self.pb = PunkBuster(self.console)
logger.setLevel(VERBOSE2)
logger.propagate = True
示例9: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
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()
示例10: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
def setUp(self):
B3TestCase.setUp(self)
self.conf = XmlConfigParser()
self.conf.setXml("""
<configuration plugin="admin">
</configuration>
""")
self.p = AdminPlugin(b3.console, self.conf)
示例11: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
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()
示例12: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
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)
示例13: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
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
示例14: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
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>
""")
示例15: setUp
# 需要导入模块: from tests import B3TestCase [as 别名]
# 或者: from tests.B3TestCase import setUp [as 别名]
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()