#!/usr/bin/python3 import doctest import importlib import logging from mini_buildd import cli, webapp LOG = logging.getLogger("mini_buildd") #: Needed for man page hack in setup.py DESCRIPTION = "Run doctests for given module" class CLI(cli.CLI): def __init__(self): super().__init__("run-doctests", DESCRIPTION) self.parser.add_argument("module", action="store", help="Complete module name like ``mini_buildd.util``") def runcli(self): webapp.pseudo_configure() result = doctest.testmod(importlib.import_module(self.args.module), verbose=False) if result.failed > 0: raise RuntimeError(f"{self.args.module}: {result}") if __name__ == "__main__": CLI().run()