source: mod_gnutls/test/doctest-mgstest.py

mod_gnutls/0.12.0
Last change on this file was 461fd38, checked in by Fiona Klute <fiona.klute@…>, 10 months ago

Automagically detect test framework modules for doctest

  • Property mode set to 100755
File size: 675 bytes
Line 
1#!/usr/bin/python3
2import doctest
3import importlib
4import sys
5from pathlib import Path
6
7if __name__ == "__main__":
8    modules = set()
9    for p in Path('mgstest').glob('**/*.py'):
10        if p.stem == '__init__':
11            modules.add('.'.join(p.parts[:-1]))
12        else:
13            modules.add('.'.join((*p.parts[:-1], p.stem)))
14
15    totals = (0, 0)
16    for m in modules:
17        mod = importlib.import_module(m)
18        result = doctest.testmod(m=mod, verbose=True)
19        totals = tuple(sum(x) for x in zip(totals, result))
20
21    fails, count = totals
22    print(f'Summary over all modules: {fails} out of {count} tests failed.')
23    if fails > 0:
24        sys.exit(1)
Note: See TracBrowser for help on using the repository browser.