tmt/cli.py
def coverage(
    context, code, test, docs,
    implemented, tested, documented, covered,
    unimplemented, untested, undocumented, uncovered, **kwargs):
    """ Show code, test and docs coverage for given stories. """
    tmt.Story._context = context

    def headfoot(text):
        """ Format simple header/footer """
        echo(style(text.rjust(4) + ' ', fg='blue'), nl=False)

    header = False
    total = code_coverage = test_coverage = docs_coverage = 0
    if not any([code, test, docs]):
        code = test = docs = True
    for story in context.obj.tree.stories():
        # Header
        if not header:
            if code:
                headfoot('code')
            if test:
                headfoot('test')
            if docs:
                headfoot('docs')
            headfoot('story')
            echo()
            header = True
        # Coverage
        if story._match(implemented, tested, documented, covered,
                unimplemented, untested, undocumented, uncovered):
            status = story.coverage(code, test, docs)
            total += 1
            code_coverage += status[0]
            test_coverage += status[1]
            docs_coverage += status[2]
    # Summary
    if code:
        headfoot('{}%'.format(round(100 * code_coverage / total)))
    if test:
        headfoot('{}%'.format(round(100 * test_coverage / total)))
    if docs:
        headfoot('{}%'.format(round(100 * docs_coverage / total)))
    headfoot('from {}'.format(listed(total, 'story')))
    echo()
 Show code, test and docs coverage for given stories. 
Show code, test and docs coverage for given stories.
Show code test and docs coverage for given stories .
def coverage(
    context, code, test, docs,
    implemented, tested, documented, covered,
    unimplemented, untested, undocumented, uncovered, **kwargs):
    tmt.Story._context = context
    def headfoot(text):
        echo(style(text.rjust(4) + ' ', fg='blue'), nl=False)
    header = False
    total = code_coverage = test_coverage = docs_coverage = 0
    if not any([code, test, docs]):
        code = test = docs = True
    for story in context.obj.tree.stories():
        if not header:
            if code:
                headfoot('code')
            if test:
                headfoot('test')
            if docs:
                headfoot('docs')
            headfoot('story')
            echo()
            header = True
        if story._match(implemented, tested, documented, covered,
                unimplemented, untested, undocumented, uncovered):
            status = story.coverage(code, test, docs)
            total += 1
            code_coverage += status[0]
            test_coverage += status[1]
            docs_coverage += status[2]
    if code:
        headfoot('{}%'.format(round(100 * code_coverage / total)))
    if test:
        headfoot('{}%'.format(round(100 * test_coverage / total)))
    if docs:
        headfoot('{}%'.format(round(100 * docs_coverage / total)))
    headfoot('from {}'.format(listed(total, 'story')))
    echo()
def coverage ( context , code , test , docs , implemented , tested , documented , covered , unimplemented , untested , undocumented , uncovered , ** kwargs ) : tmt . Story . _context = context def headfoot ( text ) : """ Format simple header/footer """ echo ( style ( text . rjust ( 4 ) + ' ' , fg = 'blue' ) , nl = False ) header = False total = code_coverage = test_coverage = docs_coverage = 0 if not any ( [ code , test , docs ] ) : code = test = docs = True for story in context . obj . tree . stories ( ) : if not header : if code : headfoot ( 'code' ) if test : headfoot ( 'test' ) if docs : headfoot ( 'docs' ) headfoot ( 'story' ) echo ( ) header = True if story . _match ( implemented , tested , documented , covered , unimplemented , untested , undocumented , uncovered ) : status = story . coverage ( code , test , docs ) total += 1 code_coverage += status [ 0 ] test_coverage += status [ 1 ] docs_coverage += status [ 2 ] if code : headfoot ( '{}%' . format ( round ( 100 * code_coverage / total ) ) ) if test : headfoot ( '{}%' . format ( round ( 100 * test_coverage / total ) ) ) if docs : headfoot ( '{}%' . format ( round ( 100 * docs_coverage / total ) ) ) headfoot ( 'from {}' . format ( listed ( total , 'story' ) ) ) echo ( )
Show code, test and docs coverage for given stories.
Show code test and docs coverage for given stories .
""" Show code, test and docs coverage for given stories. """ """ Format simple header/footer """ # Header # Coverage # Summary
context
code
test
docs
implemented
tested
documented
covered
unimplemented
untested
undocumented
uncovered