pytest

Pytest-using variant of testing.py. Will eventually replace the latter.

invocations.pytest.coverage(c, report='term', opts='', tester=None, codecov=False, additional_testers=None)

Run pytest with coverage enabled.

Assumes the pytest-cov pytest plugin is installed.

Parameters
  • report (str) – Coverage report style to use. If ‘html’, will also open in browser.

  • opts (str) – Extra runtime opts to pass to pytest.

  • tester – Specific test task object to invoke. If None (default), uses this module’s local test.

  • codecov (bool) – Whether to build XML and upload to Codecov. Requires codecov tool. Default: False.

  • additional_testers – List of additional test functions to call besides tester. If given, implies the use of --cov-append on these subsequent test runs.

Changed in version 2.4: Added the additional_testers argument.

invocations.pytest.integration(c, opts=None, pty=True, x=False, k=None, verbose=True, color=True, capture='sys', module=None)

Run the integration test suite. May be slow!

See pytest.test for description of most arguments.

invocations.pytest.test(c, verbose=True, color=True, capture='sys', module=None, k=None, x=False, opts='', pty=True, warnings=True)

Run pytest with given options.

Parameters
  • verbose (bool) – Whether to run tests in verbose mode.

  • color (bool) – Whether to request colorized output (typically only works when verbose=True.)

  • capture (str) – What type of stdout/err capturing pytest should use. Defaults to sys since pytest’s own default, fd, tends to trip up subprocesses trying to detect PTY status. Can be set to no for no capturing / useful print-debugging / etc.

  • module (str) – Select a specific test module to focus on, e.g. main to only run tests/main.py. (Note that this is a specific idiom aside from the use of -o '-k pattern'.) Default: None.

  • k (str) – Convenience passthrough for pytest -k, i.e. test selection. Default: None.

  • x (bool) – Convenience passthrough for pytest -x, i.e. fail-fast. Default: False.

  • opts (str) – Extra runtime options to hand to pytest.

  • pty (bool) – Whether to use a pty when executing pytest. Default: True.

  • warnings (bool) –

    Inverse alias for the pytest --disable_warnings flag; when this is False (i.e. called on CLI as --no-warnings), --disable-warnings will be given. Default: True.

    New in version 2.0.