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


Python pytest.main方法代码示例

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


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

示例1: test

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def test(extra_args=None):
    try:
        import pytest
    except ImportError:
        raise ImportError("Need pytest>=3.0 to run tests")
    try:
        import hypothesis  # noqa
    except ImportError:
        raise ImportError("Need hypothesis>=3.58 to run tests")
    cmd = ['--skip-slow', '--skip-network', '--skip-db']
    if extra_args:
        if not isinstance(extra_args, list):
            extra_args = [extra_args]
        cmd = extra_args
    cmd += [PKG]
    print("running: pytest {}".format(' '.join(cmd)))
    sys.exit(pytest.main(cmd)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:19,代码来源:_tester.py

示例2: generate

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def generate(proto_path, protos):
    from grpc_tools import protoc
    well_known_path = os.path.join(os.path.dirname(protoc.__file__), '_proto')

    proto_out = os.path.join(os.getcwd(), 'protos')
    proto_path.append(well_known_path)
    proto_path_args = []
    for protop in proto_path:
        proto_path_args += ['--proto_path', protop]
    cmd = [
        'grpc_tools.protoc',
        *proto_path_args,
        '--python_out', proto_out,
        '--grpc_python_out', proto_out,
        *protos
    ]
    return protoc.main(cmd) 
开发者ID:shanbay,项目名称:sea,代码行数:19,代码来源:cmds.py

示例3: run

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def run(self):
        import pytest
        import _pytest.main

        # Customize messages for pytest exit codes...
        msg = {_pytest.main.EXIT_OK: 'OK',
               _pytest.main.EXIT_TESTSFAILED: 'Tests failed',
               _pytest.main.EXIT_INTERRUPTED: 'Interrupted',
               _pytest.main.EXIT_INTERNALERROR: 'Internal error',
               _pytest.main.EXIT_USAGEERROR: 'Usage error',
               _pytest.main.EXIT_NOTESTSCOLLECTED: 'No tests collected'}

        bldobj = self.distribution.get_command_obj('build')
        bldobj.run()
        exitcode = pytest.main(self.pytest_opts)
        print(msg[exitcode])
        sys.exit(exitcode) 
开发者ID:ajelenak,项目名称:pysaxon,代码行数:19,代码来源:setup.py

示例4: pytest_addoption

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def pytest_addoption(parser):
    parser.addoption(
        "--lsof",
        action="store_true",
        dest="lsof",
        default=False,
        help="run FD checks if lsof is available",
    )

    parser.addoption(
        "--runpytest",
        default="inprocess",
        dest="runpytest",
        choices=("inprocess", "subprocess"),
        help=(
            "run pytest sub runs in tests using an 'inprocess' "
            "or 'subprocess' (python -m main) method"
        ),
    )

    parser.addini(
        "pytester_example_dir", help="directory to take the pytester example files from"
    ) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:25,代码来源:pytester.py

示例5: inline_runsource

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def inline_runsource(self, source, *cmdlineargs):
        """Run a test module in process using ``pytest.main()``.

        This run writes "source" into a temporary file and runs
        ``pytest.main()`` on it, returning a :py:class:`HookRecorder` instance
        for the result.

        :param source: the source code of the test module

        :param cmdlineargs: any extra command line arguments to use

        :return: :py:class:`HookRecorder` instance of the result

        """
        p = self.makepyfile(source)
        values = list(cmdlineargs) + [p]
        return self.inline_run(*values) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:19,代码来源:pytester.py

示例6: run

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def run(self, paths):
        """Run pytest test suite."""
        cmd = paths + self.pytest_args
        print(cmd)

        try:
            with ShortOutput(self.cmd_root) as so:
                errno = pytest.main(cmd)
            output_lines = ''.join(so.output).lower()

            if 'FAIL Required test coverage'.lower() in output_lines:
                self.coverage_fail = True

            if errno != 0:
                print("pytest failed, code {errno}".format(errno=errno))
        except CoverageError as e:
            print("Test coverage failure: " + str(e))
            self.coverage_fail = True

        covered_lines = self.parse_coverage()
        pytest_report = self.parse_pytest_report()

        results = {'coverage': covered_lines}
        if pytest_report is not None:
            results['pytest'] = pytest_report
        return results 
开发者ID:ContinuumIO,项目名称:ciocheck,代码行数:28,代码来源:tools.py

示例7: run_tests_coverage

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def run_tests_coverage():
    if __name__ == "__main__":
        pytest.main(PYTEST_ARGS) 
开发者ID:invanalabs,项目名称:invana-bot,代码行数:5,代码来源:runtests.py

示例8: test

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def test():
    """Run the tests."""
    import pytest
    exit_code = pytest.main([TEST_PATH, '-x', '--verbose'])
    return exit_code 
开发者ID:codeforamerica,项目名称:comport,代码行数:7,代码来源:manage.py

示例9: run_tests

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def run_tests(self):
        import pytest

        errno = pytest.main(self.pytest_args)
        sys.exit(errno) 
开发者ID:yang3yen,项目名称:pysm4,代码行数:7,代码来源:setup.py

示例10: run_tests

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def run_tests(self):
        # import here, cause outside the eggs aren't loaded
        import pytest
        err_no = pytest.main(self.pytest_args)
        sys.exit(err_no) 
开发者ID:it-geeks-club,项目名称:pyspectator,代码行数:7,代码来源:setup.py

示例11: run_tests

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def run_tests(self):
        import shlex
        import pytest

        errno = pytest.main(shlex.split(self.pytest_args))
        sys.exit(errno) 
开发者ID:huge-success,项目名称:sanic,代码行数:8,代码来源:setup.py

示例12: run_tests

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def run_tests(self):
        import pytest
        errno = pytest.main(self.test_args)
        sys.exit(errno) 
开发者ID:poppyred,项目名称:python-consul2,代码行数:6,代码来源:setup.py

示例13: run

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def run(self):
        """Run the flake8 linter."""
        self.distribution.fetch_build_eggs(test_requires)
        self.distribution.packages.append('tests')

        from flake8.main import Flake8Command
        flake8cmd = Flake8Command(self.distribution)
        flake8cmd.options_dict = {}
        flake8cmd.run() 
开发者ID:endgameinc,项目名称:eqllib,代码行数:11,代码来源:setup.py

示例14: run_tests

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def run_tests(self):
        """Run pytest."""
        self.distribution.fetch_build_eggs(test_requires)
        self.distribution.packages.append('tests')

        import pytest
        sys.exit(pytest.main(self.pytest_args)) 
开发者ID:endgameinc,项目名称:eqllib,代码行数:9,代码来源:setup.py

示例15: run

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import main [as 别名]
def run():
    runs = 40
    fails = 0
    for x in range(runs):
        itr = x + 1
        print('running {}'.format(itr))
        # tst = 'test_greater_eq_predicate.py::testPredicateGreaterEqMultiIssuers'
        # result = pytest.main('-x --tb=long -n 7 {}'.format(tst))
        result = pytest.main('-x')
        failed = bool(result)
        fails += int(failed)
    print("{} runs, {} failures".format(runs, fails)) 
开发者ID:hyperledger-archives,项目名称:indy-anoncreds,代码行数:14,代码来源:run_tests_multiple_times.py


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