當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。