module pycode.pytest_helper

Inheritance diagram of pyquickhelper.pycode.pytest_helper

Short summary

module pyquickhelper.pycode.pytest_helper

pytest is sometimes slow. This file provides helpers to easily run test function.

source on GitHub

Classes

class

truncated documentation

TestExecutionError

Raised when the execution of a test fails.

Functions

function

truncated documentation

run_test_function

Runs test functions from module.

Methods

method

truncated documentation

__init__

Documentation

pytest is sometimes slow. This file provides helpers to easily run test function.

source on GitHub

exception pyquickhelper.pycode.pytest_helper.TestExecutionError(module, name, exc)[source]

Bases: RuntimeError

Raised when the execution of a test fails.

source on GitHub

Parameters:
  • module – module

  • name – function name

  • exc – exception

source on GitHub

__init__(module, name, exc)[source]
Parameters:
  • module – module

  • name – function name

  • exc – exception

source on GitHub

pyquickhelper.pycode.pytest_helper.run_test_function(module, pattern='^test_.*', stop_first=False, verbose=False, fLOG=<built-in function print>)[source]

Runs test functions from module.

Parameters:
  • module – module (string or module)

  • pattern – function pattern

  • stop_first – stops at the first error or run all of them

  • verbose – prints out the name of the functions

  • fLOG – logging function

The following piece of code could also be used to run all tests not using any parameter.

fcts = [v for k, v in locals().items() if k.startswith('test_')]
for fct in fcts:
    print("run", fct.__name__)
    try:
        fct()
    except Exception as e:
        if 'missing' in str(e):
            print(e)
            continue
        raise e

source on GitHub