setuphelpers.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:setuphelpers 作者: ccpgames 项目源码 文件源码
def nose_command(verbose=True, detailed=True, cover=None):
    """Returns the NoseTest TestCommand runner.

    You can use this directly if you want, or pass any of these kwargs to
    test_command instead, while also passing nose=True.

    KWArgs:
        verbose: print verbose test output
        detailed: print extra/detailed information on test failure
        cover: string module to display a coverage report for

    Returns:
        CommandClass object
    """

    test_args = []
    if verbose:
        test_args.append("-v")
    if detailed:
        test_args.append("-d")
    if cover:
        test_args.extend(["--with-coverage", "--cov-report",
                          "term-missing", "--cov", cover])

    class NoseTest(TestCommand):
        """TestCommand subclass to enable setup.py test."""

        def finalize_options(self):
            """Fill out test_args."""

            TestCommand.finalize_options(self)
            self.test_suite = True
            self.test_args = test_args

        def run_tests(self):  # pragma: no cover
            """Nose test discovery and execution."""

            import nose
            raise SystemExit(nose.main(argv=self.test_args))

    return NoseTest
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号