当前位置: 首页>>代码示例>>Python>>正文


Python mozunit.main函数代码示例

本文整理汇总了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=-')
开发者ID:luke-chang,项目名称:gecko-1,代码行数:29,代码来源:test_httpd.py

示例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()
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:30,代码来源:test_util_templates.py

示例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')
开发者ID:luke-chang,项目名称:gecko-1,代码行数:30,代码来源:runtests.py


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