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


Python pytest.org方法代码示例

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


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

示例1: pytest_runtest_makereport

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import org [as 别名]
def pytest_runtest_makereport(item, call):
    """Make test information available in fixtures.

    See http://pytest.org/latest/example/simple.html#making-test-result-information-available-in-fixtures
    """
    outcome = yield
    rep = outcome.get_result()
    setattr(item, "rep_" + rep.when, rep) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:10,代码来源:conftest.py

示例2: run

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import org [as 别名]
def run(self):
        install_scripts.run(self)
        if not os.name == 'nt':
            return

        for filepath in self.get_outputs():
            # If we can find an executable name in the #! top line of the script
            # file, make .bat wrapper for script.
            with open(filepath, 'rt') as fobj:
                first_line = fobj.readline().lower()

            if not (first_line.startswith('#!') and 'python' in first_line):
                printer(NO_PYTHON_ERROR % filepath)
                continue

            path, fname = os.path.split(filepath)
            froot, ext = os.path.splitext(fname)
            bat_file = os.path.join(path, froot + '.bat')
            bat_contents = BAT_TEMPLATE.replace('{FNAME}', fname)

            printer('Making %s wrapper for %s' % (bat_file, filepath))
            if self.dry_run:
                continue

            with open(bat_file, 'wt') as fobj:
                fobj.write(bat_contents)


# From here: http://pytest.org/2.2.4/goodpractises.html 
开发者ID:ManiacalLabs,项目名称:BiblioPixel,代码行数:31,代码来源:setup.py

示例3: _test

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import org [as 别名]
def _test():
    """Run the unit tests.

    :return: exit code
    """
    # Make sure to import pytest in this function. For the reason, see here:
    # <http://pytest.org/latest/goodpractises.html#integration-with-setuptools-test-commands>  # NOPEP8
    import pytest
    # This runs the unit tests.
    # It also runs doctest, but only on the modules in TESTS_DIRECTORY.
    return pytest.main(PYTEST_FLAGS + [TESTS_DIRECTORY]) 
开发者ID:ThoughtWorksInc,项目名称:oktaauth,代码行数:13,代码来源:setup.py

示例4: _test_all

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import org [as 别名]
def _test_all():
    """Run lint and tests.

    :return: exit code
    """
    return _lint() + _test()


# The following code is to allow tests to be run with `python setup.py test'.
# The main reason to make this possible is to allow tests to be run as part of
# Setuptools' automatic run of 2to3 on the source code. The recommended way to
# run tests is still `paver test_all'.
# See <http://pythonhosted.org/setuptools/python3.html>
# Code based on <http://pytest.org/latest/goodpractises.html#integration-with-setuptools-test-commands>  # NOPEP8 
开发者ID:ThoughtWorksInc,项目名称:oktaauth,代码行数:16,代码来源:setup.py

示例5: test

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import org [as 别名]
def test(doctest=True, verbose=True, coverage=False):
    """
    Run the test suite.

    Uses `py.test <http://pytest.org/>`__ to discover and run the tests.

    Parameters
    ----------

    doctest : bool
        If ``True``, will run the doctests as well (code examples that start
        with a ``>>>`` in the docs).
    verbose : bool
        If ``True``, will print extra information during the test run.
    coverage : bool
        If ``True``, will run test coverage analysis on the code as well.
        Requires ``pytest-cov``.

    Raises
    ------

    AssertionError
        If pytest returns a non-zero error code indicating that some tests have
        failed.

    """
    import pytest

    package = __name__
    args = []
    if verbose:
        args.append("-vv")
    if coverage:
        args.append("--cov={}".format(package))
        args.append("--cov-report=term-missing")
    if doctest:
        args.append("--doctest-modules")
    args.append("--pyargs")
    args.append(package)
    status = pytest.main(args)
    assert status == 0, "Some tests have failed." 
开发者ID:fatiando,项目名称:pooch,代码行数:43,代码来源:__init__.py

示例6: test_storage_provider_azure

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import org [as 别名]
def test_storage_provider_azure(release_config_azure, tmpdir):
    exercise_storage_provider(tmpdir, 'azure_block_blob', release_config_azure)


# TODO(cmaloney): Add skipping when not run under CI with the environment variables
# So devs without the variables don't see expected failures https://pytest.org/latest/skipping.html 
开发者ID:dcos,项目名称:dcos,代码行数:8,代码来源:test_release.py

示例7: pytest_collection_modifyitems

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import org [as 别名]
def pytest_collection_modifyitems(config, items):
    """Handle custom markers.

    pytest hook called after collection has been performed.

    Adds a marker named "gui" which can be used to filter gui tests from the
    command line.

    For example:

        pytest -m "not gui"  # run all tests except gui tests
        pytest -m "gui"  # run only gui tests

    It also handles the platform specific markers by translating them to skipif
    markers.

    Args:
        items: list of _pytest.main.Node items, where each item represents
               a python test that will be executed.

    Reference:
        http://pytest.org/latest/plugins.html
    """
    remaining_items = []
    deselected_items = []

    for item in items:
        deselected = False

        if 'qapp' in getattr(item, 'fixturenames', ()):
            item.add_marker('gui')

        if hasattr(item, 'module'):
            test_basedir = pathlib.Path(__file__).parent
            module_path = pathlib.Path(item.module.__file__)
            module_root_dir = module_path.relative_to(test_basedir).parts[0]

            assert module_root_dir in ['end2end', 'unit', 'helpers',
                                       'test_conftest.py']
            if module_root_dir == 'end2end':
                item.add_marker(pytest.mark.end2end)

        _apply_platform_markers(config, item)
        if list(item.iter_markers('xfail_norun')):
            item.add_marker(pytest.mark.xfail(run=False))
        if list(item.iter_markers('js_prompt')):
            if config.webengine:
                item.add_marker(pytest.mark.skipif(
                    PYQT_VERSION <= 0x050700,
                    reason='JS prompts are not supported with PyQt 5.7'))

        if deselected:
            deselected_items.append(item)
        else:
            remaining_items.append(item)

    config.hook.pytest_deselected(items=deselected_items)
    items[:] = remaining_items 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:60,代码来源:conftest.py

示例8: run_setup

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import org [as 别名]
def run_setup(with_cext):
    kwargs = {}
    if with_cext:
        kwargs["ext_modules"] = ext_modules
    else:
        kwargs["ext_modules"] = []

    setup(
        name="SQLAlchemy",
        version=VERSION,
        description="Database Abstraction Library",
        author="Mike Bayer",
        author_email="mike_mp@zzzcomputing.com",
        url="http://www.sqlalchemy.org",
        packages=find_packages("lib"),
        package_dir={"": "lib"},
        license="MIT License",
        cmdclass=cmdclass,
        tests_require=["pytest >= 2.5.2", "mock", "pytest-xdist"],
        long_description=readme,
        classifiers=[
            "Development Status :: 5 - Production/Stable",
            "Intended Audience :: Developers",
            "License :: OSI Approved :: MIT License",
            "Programming Language :: Python",
            "Programming Language :: Python :: 3",
            "Programming Language :: Python :: Implementation :: CPython",
            "Programming Language :: Python :: Implementation :: PyPy",
            "Topic :: Database :: Front-Ends",
            "Operating System :: OS Independent",
        ],
        distclass=Distribution,
        extras_require={
            "mysql": ["mysqlclient"],
            "pymysql": ["pymysql"],
            "postgresql": ["psycopg2"],
            "postgresql_pg8000": ["pg8000"],
            "postgresql_psycopg2cffi": ["psycopg2cffi"],
            "oracle": ["cx_oracle"],
            "mssql_pyodbc": ["pyodbc"],
            "mssql_pymssql": ["pymssql"],
        },
        **kwargs
    ) 
开发者ID:python-poetry,项目名称:poetry,代码行数:46,代码来源:setup.py

示例9: test

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import org [as 别名]
def test(doctest=True, verbose=True, coverage=False, figures=True):
    """
    Run the test suite.

    Uses `py.test <http://pytest.org/>`__ to discover and run the tests.

    Parameters
    ----------

    doctest : bool
        If ``True``, will run the doctests as well (code examples that start
        with a ``>>>`` in the docs).
    verbose : bool
        If ``True``, will print extra information during the test run.
    coverage : bool
        If ``True``, will run test coverage analysis on the code as well.
        Requires ``pytest-cov``.
    figures : bool
        If ``True``, will test generated figures against saved baseline
        figures.  Requires ``pytest-mpl`` and ``matplotlib``.

    Raises
    ------

    AssertionError
        If pytest returns a non-zero error code indicating that some tests have
        failed.

    """
    import pytest

    package = __name__
    args = []
    if verbose:
        args.append("-vv")
    if coverage:
        args.append("--cov={}".format(package))
        args.append("--cov-report=term-missing")
    if doctest:
        args.append("--doctest-modules")
    if figures:
        args.append("--mpl")
    args.append("--pyargs")
    args.append(package)
    status = pytest.main(args)
    assert status == 0, "Some tests have failed." 
开发者ID:fatiando,项目名称:verde,代码行数:48,代码来源:__init__.py

示例10: test

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import org [as 别名]
def test(doctest=True, verbose=True, coverage=False, figures=True):
    """
    Run the test suite.

    Uses `pytest <http://pytest.org/>`__ to discover and run the tests. If you
    haven't already, you can install it with `conda
    <http://conda.pydata.org/>`__ or `pip <https://pip.pypa.io/en/stable/>`__.

    Parameters
    ----------

    doctest : bool
        If ``True``, will run the doctests as well (code examples that start
        with a ``>>>`` in the docs).
    verbose : bool
        If ``True``, will print extra information during the test run.
    coverage : bool
        If ``True``, will run test coverage analysis on the code as well.
        Requires ``pytest-cov``.
    figures : bool
        If ``True``, will test generated figures against saved baseline
        figures.  Requires ``pytest-mpl`` and ``matplotlib``.

    Raises
    ------

    AssertionError
        If pytest returns a non-zero error code indicating that some tests have
        failed.

    """
    import pytest

    show_versions()

    package = __name__

    args = []
    if verbose:
        args.append("-vv")
    if coverage:
        args.append("--cov={}".format(package))
        args.append("--cov-report=term-missing")
    if doctest:
        args.append("--doctest-modules")
    if figures:
        args.append("--mpl")
    args.append("--pyargs")
    args.append(package)
    status = pytest.main(args)
    assert status == 0, "Some tests have failed." 
开发者ID:GenericMappingTools,项目名称:pygmt,代码行数:53,代码来源:__init__.py

示例11: test

# 需要导入模块: import pytest [as 别名]
# 或者: from pytest import org [as 别名]
def test(doctest=True, verbose=True, coverage=False, figures=False):
    """
    Run the test suite.

    Uses `py.test <http://pytest.org/>`__ to discover and run the tests.

    Parameters
    ----------

    doctest : bool
        If ``True``, will run the doctests as well (code examples that start
        with a ``>>>`` in the docs).
    verbose : bool
        If ``True``, will print extra information during the test run.
    coverage : bool
        If ``True``, will run test coverage analysis on the code as well.
        Requires ``pytest-cov``.
    figures : bool
        If ``True``, will test generated figures against saved baseline
        figures.  Requires ``pytest-mpl`` and ``matplotlib``.

    Raises
    ------

    AssertionError
        If pytest returns a non-zero error code indicating that some tests have
        failed.

    """
    import pytest

    package = __name__
    args = []
    if verbose:
        args.append("-vv")
    if coverage:
        args.append("--cov={}".format(package))
        args.append("--cov-report=term-missing")
    if doctest:
        args.append("--doctest-modules")
    if figures:
        args.append("--mpl")
    args.append("--pyargs")
    args.append(package)
    status = pytest.main(args)
    assert status == 0, "Some tests have failed." 
开发者ID:fatiando,项目名称:harmonica,代码行数:48,代码来源:__init__.py


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