stouputils.all_doctests.main module#

launch_tests(
root_dir: str,
strict: bool = True,
pattern: str = '*',
) int[source]#

Main function to launch tests for all modules in the given directory.

Parameters:
  • root_dir (str) – Root directory to search for modules

  • strict (bool) – Modify the FORCE_RAISE_EXCEPTION configuration to True

  • pattern (str) – Pattern to filter module names (fnmatch style, e.g., ‘typ’, ‘io’, etc.)

Returns:

The number of failed tests

Return type:

int

Examples

>>> launch_tests("unknown_dir")
Traceback (most recent call last):
        ...
ValueError: No modules found in 'unknown_dir'
> if launch_tests("/path/to/source") > 0:
        sys.exit(1)
[PROGRESS HH:MM:SS] Importing module 'module1'  took 0.001s
[PROGRESS HH:MM:SS] Importing module 'module2'  took 0.002s
[PROGRESS HH:MM:SS] Importing module 'module3'  took 0.003s
[PROGRESS HH:MM:SS] Importing module 'module4'  took 0.004s
[INFO HH:MM:SS] Testing 4 modules...
[PROGRESS HH:MM:SS] Testing module 'module1'    took 0.005s
[PROGRESS HH:MM:SS] Testing module 'module2'    took 0.006s
[PROGRESS HH:MM:SS] Testing module 'module3'    took 0.007s
[PROGRESS HH:MM:SS] Testing module 'module4'    took 0.008s