Python pytest.org() Examples
The following are 12
code examples of pytest.org().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pytest
, or try the search function
.
Example #1
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 5 votes |
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)
Example #2
Source File: setup.py From BiblioPixel with MIT License | 5 votes |
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
Example #3
Source File: setup.py From oktaauth with Apache License 2.0 | 5 votes |
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])
Example #4
Source File: setup.py From oktaauth with Apache License 2.0 | 5 votes |
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
Example #5
Source File: __init__.py From pooch with BSD 3-Clause "New" or "Revised" License | 5 votes |
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."
Example #6
Source File: test_release.py From dcos with Apache License 2.0 | 5 votes |
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
Example #7
Source File: conftest.py From qutebrowser with GNU General Public License v3.0 | 4 votes |
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
Example #8
Source File: setup.py From poetry with MIT License | 4 votes |
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 )
Example #9
Source File: __init__.py From verde with BSD 3-Clause "New" or "Revised" License | 4 votes |
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."
Example #10
Source File: __init__.py From pygmt with BSD 3-Clause "New" or "Revised" License | 4 votes |
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."
Example #11
Source File: __init__.py From harmonica with BSD 3-Clause "New" or "Revised" License | 4 votes |
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."
Example #12
Source File: __init__.py From rockhound with BSD 3-Clause "New" or "Revised" License | 4 votes |
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."