本文整理汇总了Python中mozunit.main函数的典型用法代码示例。如果您正苦于以下问题:Python main函数的具体用法?Python main怎么用?Python main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了main函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_routes
def test_routes(server):
assert server.routes is not None
def test_is_alive(server):
assert server.is_alive == False
server.start()
assert server.is_alive == True
def test_handler(server):
counter = 0
@json_handler
def handler(request, response):
return {"count": counter}
route = ("GET", "/httpd/test_handler", handler)
server.router.register(*route)
server.start()
url = server.get_url("/httpd/test_handler")
body = urllib2.urlopen(url).read()
res = json.loads(body)
assert res["count"] == counter
if __name__ == "__main__":
mozunit.main('--log-tbpl=-')
示例2: test_merge_diff_types
expected = {'x': [1, 2, 3, 4]} # dest first
self.assertEqual(merge_to(source, dest), expected)
self.assertEqual(dest, expected)
def test_merge_diff_types(self):
source = {'x': [1, 2]}
dest = {'x': 'abc'}
expected = {'x': [1, 2]} # source wins
self.assertEqual(merge_to(source, dest), expected)
self.assertEqual(dest, expected)
def test_merge(self):
first = {'a': 1, 'b': 2, 'd': 11}
second = {'b': 20, 'c': 30}
third = {'c': 300, 'd': 400}
expected = {
'a': 1,
'b': 20,
'c': 300,
'd': 400,
}
self.assertEqual(merge(first, second, third), expected)
# inputs haven't changed..
self.assertEqual(first, {'a': 1, 'b': 2, 'd': 11})
self.assertEqual(second, {'b': 20, 'c': 30})
self.assertEqual(third, {'c': 300, 'd': 400})
if __name__ == '__main__':
mozunit.main()
示例3: testAttribute
self.assertEqual("long", m.params[2].realtype.type.name)
def testAttribute(self):
i = self.p.parse("""[uuid(abc)] interface foo {
attribute long bar;
};""", filename='f')
self.assertTrue(isinstance(i, xpidl.IDL))
self.assertTrue(isinstance(i.productions[0], xpidl.Interface))
iface = i.productions[0]
a = iface.members[0]
self.assertTrue(isinstance(a, xpidl.Attribute))
self.assertEqual("bar", a.name)
self.assertEqual("long", a.type)
def testOverloadedVirtual(self):
i = self.p.parse("""[uuid(abc)] interface foo {
attribute long bar;
void getBar();
};""", filename='f')
self.assertTrue(isinstance(i, xpidl.IDL))
class FdMock:
def write(self, s):
pass
try:
header.print_header(i, FdMock(), filename='f')
except Exception as e:
self.assertEqual(e.args[0], "Unexpected overloaded virtual method GetBar in interface foo")
if __name__ == '__main__':
mozunit.main(runwith='unittest')