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


Python unittest2.main方法代码示例

本文整理汇总了Python中unittest2.main方法的典型用法代码示例。如果您正苦于以下问题:Python unittest2.main方法的具体用法?Python unittest2.main怎么用?Python unittest2.main使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest2的用法示例。


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

示例1: testRoutesInheritance

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def testRoutesInheritance(self):
    errors = ''
    errors += self._VerifyInheritance(main._UNAUTHENTICATED_ROUTES,
                                      handlers.BaseHandler)
    errors += self._VerifyInheritance(main._UNAUTHENTICATED_AJAX_ROUTES,
                                      handlers.BaseAjaxHandler)
    errors += self._VerifyInheritance(main._USER_ROUTES,
                                      handlers.AuthenticatedHandler)
    errors += self._VerifyInheritance(main._AJAX_ROUTES,
                                      handlers.AuthenticatedAjaxHandler)
    errors += self._VerifyInheritance(main._ADMIN_ROUTES,
                                      handlers.AdminHandler)
    errors += self._VerifyInheritance(main._ADMIN_AJAX_ROUTES,
                                      handlers.AdminAjaxHandler)
    errors += self._VerifyInheritance(main._CRON_ROUTES,
                                      handlers.BaseCronHandler)
    errors += self._VerifyInheritance(main._TASK_ROUTES,
                                      handlers.BaseTaskHandler)
    if errors:
      self.fail('Some handlers do not inherit from the correct classes:\n' +
                errors) 
开发者ID:google,项目名称:gae-secure-scaffold-python,代码行数:23,代码来源:main_test.py

示例2: testStrictHandlerMethodRouting

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def testStrictHandlerMethodRouting(self):
    """Checks that handler functions properly limit applicable HTTP methods."""
    router = webapp2.Router(main._USER_ROUTES + main._AJAX_ROUTES +
                            main._ADMIN_ROUTES + main._ADMIN_AJAX_ROUTES)
    routes = router.match_routes + router.build_routes.values()
    failed_routes = []
    while routes:
      route = routes.pop()
      if issubclass(route.__class__, webapp2_extras.routes.MultiRoute):
        routes += list(route.get_routes())
        continue

      if issubclass(route.handler, webapp2.RedirectHandler):
        continue

      if route.handler_method and not route.methods:
        failed_routes.append('%s (%s)' % (route.template,
                                          route.handler.__name__))

    if failed_routes:
      self.fail('Some handlers specify a handler_method but are missing a '
                'methods" attribute and may be vulnerable to XSRF via GET '
                'requests:\n * ' + '\n * '.join(failed_routes)) 
开发者ID:google,项目名称:gae-secure-scaffold-python,代码行数:25,代码来源:main_test.py

示例3: testCatchBreakInstallsHandler

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def testCatchBreakInstallsHandler(self):
        module = sys.modules['unittest2.main']
        original = module.installHandler
        def restore():
            module.installHandler = original
        self.addCleanup(restore)

        self.installed = False
        def fakeInstallHandler():
            self.installed = True
        module.installHandler = fakeInstallHandler
        
        program = self.program
        program.catchbreak = True
        
        program.testRunner = FakeRunner
        
        program.runTests()
        self.assertTrue(self.installed) 
开发者ID:Lithium876,项目名称:ConTroll_Remote_Access_Trojan,代码行数:21,代码来源:test_program.py

示例4: test_sphinx_nop

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def test_sphinx_nop(self):
        """
        Long and Sphinx- (and docstring!)-rich docstrings don't get mangled.
        """
        ds = \
    """
    Phasellus purus.

    :param int arg: Cras placerat accumsan nulla.

    >>> print("hello")
    hello

    Aliquam erat volutpat.  Nunc eleifend leo vitae magna.  In id erat non orci
    commodo lobortis.  Proin neque massa, cursus ut, gravida ut, lobortis eget,
    lacus.  Sed diam.  Praesent fermentum tempor tellus.  Nullam tempus.
    """
        self.assertEqual(
            ds,
            main(["test"], ds)
        ) 
开发者ID:glyph,项目名称:python-docstring-mode,代码行数:23,代码来源:test_docstring_wrap.py

示例5: __call__

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def __call__(self, test_fun):
        msg = "Quantifier Eliminator for %s not available" % self.logic
        cond = len(get_env().factory.all_quantifier_eliminators(logic=self.logic)) == 0
        @unittest.skipIf(cond, msg)
        @wraps(test_fun)
        def wrapper(*args, **kwargs):
            return test_fun(*args, **kwargs)
        return wrapper


# Export a main function 
开发者ID:pysmt,项目名称:pysmt,代码行数:13,代码来源:__init__.py

示例6: __main__

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def __main__():
    unittest.main() 
开发者ID:scalyr,项目名称:scalyr-agent-2,代码行数:4,代码来源:test_pyecdsa.py

示例7: main_module

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def main_module():
    """
    Return the module name of the __main__ module - i.e. the filename with the
    path and .py extension stripped. Useful to run the tests in the current file but
    using the proper module prefix instead of '__main__', as follows:
        if __name__ == '__main__':
            unittest.main(module=main_module())
    """
    return os.path.splitext(os.path.basename(__main__.__file__))[0] 
开发者ID:apache,项目名称:qpid-dispatch,代码行数:11,代码来源:system_test.py

示例8: test_okay

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def test_okay(self):
        # When forking from the master process, Mitogen had nothing to do with
        # setting up stdio -- that was inherited wherever the Master is running
        # (supervisor, iTerm, etc). When forking from a Mitogen child context
        # however, Mitogen owns all of fd 0, 1, and 2, and during the fork
        # procedure, it deletes all of these descriptors. That leaves the
        # process in a weird state that must be handled by some combination of
        # fork.py and ExternalContext.main().

        # Below we simply test whether ExternalContext.main() managed to boot
        # successfully. In future, we need lots more tests.
        c1 = self.router.fork()
        c2 = self.router.fork(via=c1)
        self.assertEquals(123, c2.call(ping)) 
开发者ID:dw,项目名称:mitogen,代码行数:16,代码来源:fork_test.py

示例9: __init__

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def __init__(self, latch, **kwargs):
        super(MyService, self).__init__(**kwargs)
        # used to wake up main thread once client has made its request
        self.latch = latch 
开发者ID:dw,项目名称:mitogen,代码行数:6,代码来源:unix_test.py

示例10: test_exec_guard

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def test_exec_guard(self):
        touched = self.call("derp.py", self.HAS_EXEC_GUARD)
        bits = touched.decode().split()
        self.assertEquals(bits[-3:], ['def', 'main():', 'pass']) 
开发者ID:dw,项目名称:mitogen,代码行数:6,代码来源:responder_test.py

示例11: test_NonExit

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def test_NonExit(self):
        program = unittest2.main(exit=False,
                                argv=["foobar"],
                                testRunner=unittest2.TextTestRunner(stream=StringIO()),
                                testLoader=self.FooBarLoader())
        self.assertTrue(hasattr(program, 'result')) 
开发者ID:Lithium876,项目名称:ConTroll_Remote_Access_Trojan,代码行数:8,代码来源:test_program.py

示例12: test_Exit

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def test_Exit(self):
        self.assertRaises(
            SystemExit,
            unittest2.main,
            argv=["foobar"],
            testRunner=unittest2.TextTestRunner(stream=StringIO()),
            exit=True,
            testLoader=self.FooBarLoader()) 
开发者ID:Lithium876,项目名称:ConTroll_Remote_Access_Trojan,代码行数:10,代码来源:test_program.py

示例13: test_ExitAsDefault

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def test_ExitAsDefault(self):
        self.assertRaises(
            SystemExit,
            unittest2.main,
            argv=["foobar"],
            testRunner=unittest2.TextTestRunner(stream=StringIO()),
            testLoader=self.FooBarLoader()) 
开发者ID:Lithium876,项目名称:ConTroll_Remote_Access_Trojan,代码行数:9,代码来源:test_program.py

示例14: test_self

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def test_self(self):
        """
        This module's, class's, & method's docstrings are fine and therefore
        not mangled.  They're all interesting because they have different
        indentations.
        """
        for ds in (__doc__, self.__class__.__doc__, self.test_self.__doc__):
            self.assertEqual(
                ds,
                main(["test"], ds)
            ) 
开发者ID:glyph,项目名称:python-docstring-mode,代码行数:13,代码来源:test_docstring_wrap.py

示例15: test_epytext_nop

# 需要导入模块: import unittest2 [as 别名]
# 或者: from unittest2 import main [as 别名]
def test_epytext_nop(self):
        """
        wrapPythonDocstring has an impressive multi-paragraph docstring full of
        epytext and doesn't get mangled.
        """
        self.assertEqual(
            wrapPythonDocstring.__doc__,
            main(["test"], wrapPythonDocstring.__doc__)
        ) 
开发者ID:glyph,项目名称:python-docstring-mode,代码行数:11,代码来源:test_docstring_wrap.py


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