stouputils.all_doctests.launch module#
- launch_tests(
- root_dir: str,
- strict: bool = True,
- pattern: str = '*',
Main function to launch tests for all modules in the given directory.
- Parameters:
root_dir – Root directory to search for modules
strict – Modify the FORCE_RAISE_EXCEPTION configuration to True
pattern – Pattern to filter module names (fnmatch style, e.g., ‘typ’, ‘io’, etc.)
- Returns:
The number of failed tests
>>> 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
- find_modules(root_dir: str, dir_to_check: str) list[str][source]#
Dotted names of the modules under
root_dir, the shallowest first and then in alphabetical order.- Parameters:
dir_to_check – Folder the names are relative to, the one put on
sys.path.- Raises:
ValueError – If
root_dirholds no module.
- filter_modules(
- module_paths: list[str],
- pattern: str,
- root_dir: str,
The module names matching an fnmatch pattern,
"*"keeping them all.>>> filter_modules(["pkg.io", "pkg.io.csv", "pkg.typing"], "*io*", "pkg") ['pkg.io', 'pkg.io.csv']
- Raises:
ValueError – If no module matches, naming the candidates.