| 1 |
#!/usr/bin/python3 |
| 2 |
import doctest |
| 3 |
import importlib |
| 4 |
import logging |
| 5 |
|
| 6 |
from mini_buildd import cli, webapp |
| 7 |
|
| 8 |
LOG = logging.getLogger("mini_buildd") |
| 9 |
|
| 10 |
#: Needed for man page hack in setup.py |
| 11 |
DESCRIPTION = "Run doctests for given module" |
| 12 |
|
| 13 |
|
| 14 |
class CLI(cli.CLI): |
| 15 |
def __init__(self): |
| 16 |
super().__init__("run-doctests", DESCRIPTION) |
| 17 |
self.parser.add_argument("module", action="store", help="Complete module name like ``mini_buildd.util``") |
| 18 |
|
| 19 |
def runcli(self): |
| 20 |
webapp.pseudo_configure() |
| 21 |
result = doctest.testmod(importlib.import_module(self.args.module), verbose=False) |
| 22 |
if result.failed > 0: |
| 23 |
raise RuntimeError(f"{self.args.module}: {result}") |
| 24 |
|
| 25 |
|
| 26 |
if __name__ == "__main__": |
| 27 |
CLI().run() |