本文整理汇总了Python中bravo.config.BravoConfigParser类的典型用法代码示例。如果您正苦于以下问题:Python BravoConfigParser类的具体用法?Python BravoConfigParser怎么用?Python BravoConfigParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BravoConfigParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestBravoFactoryPacks
class TestBravoFactoryPacks(unittest.TestCase):
"""
The plugin pack system should work.
"""
def test_pack_beta(self):
"""
The "beta" plugin pack should always work. Period.
"""
self.name = "unittest"
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
d = {
"mode" : "creative",
"packs" : "beta",
"port" : "0",
"serializer" : "memory",
"url" : "",
}
for k, v in d.items():
self.bcp.set("world unittest", k, v)
self.f = BravoFactory(self.bcp, self.name)
# And now start the factory.
self.f.startFactory()
# And stop it, too.
self.f.stopFactory()
示例2: TestBravoFactoryPacks
class TestBravoFactoryPacks(unittest.TestCase):
"""
The plugin pack system should work.
"""
def test_pack_beta(self):
"""
The "beta" plugin pack should always work. Period.
"""
self.d = tempfile.mkdtemp()
self.name = "unittest"
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
d = {
"authenticator": "offline",
"mode": "creative",
"packs": "beta",
"port": "0",
"serializer": "alpha",
"url": "file://%s" % self.d,
}
for k, v in d.items():
self.bcp.set("world unittest", k, v)
self.f = BravoFactory(self.bcp, self.name)
# And now start the factory.
self.f.startFactory()
def tearDown(self):
self.f.stopFactory()
shutil.rmtree(self.d)
示例3: TestWorldConfig
class TestWorldConfig(unittest.TestCase):
def setUp(self):
self.name = "unittest"
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "")
self.bcp.set("world unittest", "serializer", "memory")
self.w = World(self.bcp, self.name)
self.w.pipeline = []
def test_trivial(self):
pass
def test_world_configured_seed(self):
"""
Worlds can have their seed set via configuration.
"""
self.bcp.set("world unittest", "seed", "42")
self.w.start()
self.assertEqual(self.w.level.seed, 42)
self.w.stop()
示例4: setUp
def setUp(self):
# Set up world.
self.name = "unittest"
self.d = tempfile.mkdtemp()
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "file://%s" % self.d)
self.bcp.set("world unittest", "serializer", "alpha")
self.w = World(self.bcp, self.name)
self.w.pipeline = []
self.w.start()
# And finally the mock factory.
self.f = PhysicsMockFactory()
self.f.world = self.w
# Using dig hook to grab the plugin since the build hook was nuked in
# favor of the automaton interface.
pp = {"factory": self.f}
self.p = bravo.plugin.retrieve_plugins(IDigHook, parameters=pp)
if "water" not in self.p:
raise unittest.SkipTest("Plugin not present")
self.hook = self.p["water"]
示例5: setUp
def setUp(self):
# Same setup as World, because Factory is very automagical.
self.name = "unittest"
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "port", "0")
self.bcp.set("world unittest", "mode", "creative")
self.f = BravoFactory(self.bcp, self.name)
示例6: setUp
def setUp(self):
self.name = "unittest"
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "")
self.bcp.set("world unittest", "serializer", "memory")
self.w = World(self.bcp, self.name)
self.w.pipeline = []
示例7: setUp
def setUp(self):
self.name = "unittest"
self.d = tempfile.mkdtemp()
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "file://%s" % self.d)
self.bcp.set("world unittest", "serializer", "alpha")
self.w = World(self.bcp, self.name)
self.w.pipeline = []
self.w.start()
示例8: TestWorld
class TestWorld(unittest.TestCase):
def setUp(self):
self.name = "unittest"
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "")
self.bcp.set("world unittest", "serializer", "memory")
self.w = World(self.bcp, self.name)
self.w.pipeline = []
self.w.start()
def tearDown(self):
self.w.stop()
def test_trivial(self):
pass
def test_load_player_initial(self):
"""
Calling load_player() on a player which has never been loaded should
not result in an exception. Instead, the player should be returned,
wrapped in a Deferred.
"""
# For bonus points, assert that the player's username is correct.
d = self.w.load_player("unittest")
@d.addCallback
def cb(player):
self.assertEqual(player.username, "unittest")
return d
示例9: setUp
def setUp(self):
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "")
self.bcp.set("world unittest", "serializer", "memory")
self.w = World(self.bcp, "unittest")
self.w.pipeline = []
self.w.start()
self.f = GrassMockFactory()
self.f.world = self.w
self.w.factory = self.f
plugins = retrieve_plugins(IAutomaton, factory=self.f)
self.hook = plugins["grass"]
示例10: setUp
def setUp(self):
# Set up world.
self.name = "unittest"
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "")
self.bcp.set("world unittest", "serializer", "memory")
self.w = World(self.bcp, self.name)
self.w.pipeline = []
self.w.start()
# And finally the mock factory.
self.f = RedstoneMockFactory()
self.f.world = self.w
self.p = retrieve_plugins(IDigHook, factory=self.f)
self.hook = self.p["redstone"]
示例11: setUp
def setUp(self):
# Set up world.
self.name = "unittest"
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "")
self.bcp.set("world unittest", "serializer", "memory")
self.w = World(self.bcp, self.name)
self.w.pipeline = []
self.w.start()
# And finally the mock factory.
self.f = PhysicsMockFactory()
self.f.world = self.w
# Using dig hook to grab the plugin since the build hook was nuked in
# favor of the automaton interface.
self.p = bravo.plugin.retrieve_plugins(IDigHook, factory=self.f)
self.hook = self.p["water"]
示例12: setUp
def setUp(self):
self.d = tempfile.mkdtemp()
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "file://%s" % self.d)
self.bcp.set("world unittest", "serializer", "alpha")
self.w = World(self.bcp, "unittest")
self.w.pipeline = []
self.w.start()
self.f = GrassMockFactory()
self.f.world = self.w
self.w.factory = self.f
pp = {"factory": self.f}
plugins = retrieve_plugins(IAutomaton, parameters=pp)
if "grass" not in plugins:
raise unittest.SkipTest("Plugin not present")
self.hook = plugins["grass"]
示例13: TestGrass
class TestGrass(TestCase):
def setUp(self):
self.bcp = BravoConfigParser()
self.bcp.add_section("world unittest")
self.bcp.set("world unittest", "url", "")
self.bcp.set("world unittest", "serializer", "memory")
self.w = World(self.bcp, "unittest")
self.w.pipeline = []
self.w.start()
self.f = GrassMockFactory()
self.f.world = self.w
self.w.factory = self.f
plugins = retrieve_plugins(IAutomaton, factory=self.f)
self.hook = plugins["grass"]
def tearDown(self):
self.w.stop()
def test_trivial(self):
pass
@inlineCallbacks
def test_not_dirt(self):
"""
Blocks which aren't dirt by the time they're processed will be
ignored.
"""
chunk = yield self.w.request_chunk(0, 0)
chunk.set_block((0, 0, 0), blocks["bedrock"].slot)
# Run the loop once.
self.hook.feed((0, 0, 0))
self.hook.process()
# We shouldn't have any pending blocks now.
self.assertFalse(self.hook.tracked)
@inlineCallbacks
def test_unloaded_chunk(self):
"""
The grass automaton can't load chunks, so it will stop tracking blocks
on the edge of the loaded world.
"""
chunk = yield self.w.request_chunk(0, 0)
chunk.set_block((0, 0, 0), blocks["dirt"].slot)
# Run the loop once.
self.hook.feed((0, 0, 0))
self.hook.process()
# We shouldn't have any pending blocks now.
self.assertFalse(self.hook.tracked)
@inlineCallbacks
def test_surrounding(self):
"""
When surrounded by eight grassy neighbors, dirt should turn into grass
immediately.
"""
chunk = yield self.w.request_chunk(0, 0)
# Set up grassy surroundings.
for x, z in product(xrange(0, 3), repeat=2):
chunk.set_block((x, 0, z), blocks["grass"].slot)
# Our lone Cinderella.
chunk.set_block((1, 0, 1), blocks["dirt"].slot)
# Do the actual hook run. This should take exactly one run.
self.hook.feed((1, 0, 1))
self.hook.process()
self.assertFalse(self.hook.tracked)
self.assertEqual(chunk.get_block((1, 0, 1)), blocks["grass"].slot)
def test_surrounding_not_dirt(self):
"""
Blocks which aren't dirt by the time they're processed will be
ignored, even when surrounded by grass.
"""
d = self.w.request_chunk(0, 0)
@d.addCallback
def cb(chunk):
# Set up grassy surroundings.
for x, z in product(xrange(0, 3), repeat=2):
chunk.set_block((x, 0, z), blocks["grass"].slot)
chunk.set_block((1, 0, 1), blocks["bedrock"].slot)
#.........这里部分代码省略.........
示例14: TestBravoConfigParser
class TestBravoConfigParser(unittest.TestCase):
def setUp(self):
self.bcp = BravoConfigParser()
self.bcp.add_section("unittest")
def test_trivial(self):
pass
def test_getlist(self):
self.bcp.set("unittest", "l", "a,b,c,d")
self.assertEqual(self.bcp.getlist("unittest", "l"), ["a", "b", "c", "d"])
def test_getlist_separator(self):
self.bcp.set("unittest", "l", "a:b:c:d")
self.assertEqual(self.bcp.getlist("unittest", "l", ":"), ["a", "b", "c", "d"])
def test_getlist_empty(self):
self.bcp.set("unittest", "l", "")
self.assertEqual(self.bcp.getlist("unittest", "l"), [])
def test_getlist_whitespace(self):
self.bcp.set("unittest", "l", " ")
self.assertEqual(self.bcp.getlist("unittest", "l"), [])
def test_getdefault(self):
self.assertEqual(self.bcp.getdefault("unittest", "fake", ""), "")
def test_getdefault_no_section(self):
self.assertEqual(self.bcp.getdefault("fake", "fake", ""), "")
def test_getbooleandefault(self):
self.assertEqual(self.bcp.getbooleandefault("unittest", "fake", True), True)
def test_getintdefault(self):
self.assertEqual(self.bcp.getintdefault("unittest", "fake", 42), 42)
def test_getlistdefault(self):
self.assertEqual(self.bcp.getlistdefault("unittest", "fake", []), [])
示例15: setUp
def setUp(self):
self.bcp = BravoConfigParser()
self.bcp.add_section("unittest")