How to use pycobertura - 10 common examples

To help you get started, we’ve selected a few pycobertura examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aconrad / pycobertura / tests / test_cobertura.py View on Github external
Line(2, '    pass\n', True, None),
            Line(3, '\n', None, None),
            Line(4, 'def bar():\n', True, None),
            Line(5, "    a = 'a'\n", False, None),
            Line(6, "    b = 'b'\n", False, None),
        ],
        'dummy/dummy2.py': [
            Line(1, 'def baz():\n', True, None),
            Line(2, '    pass\n', True, None)
        ],
        'dummy/dummy4.py': [
            Line(1, 'def barbaz():\n', False, None),
            Line(2, '    pass\n', False, None),
            Line(3, '\n', None, None),
            Line(4, 'def foobarbaz():\n', False, None),
            Line(5, '    a = 1 + 3\n', False, None),
            Line(6, '    pass\n', False, None)
        ],
    }
    for filename in cobertura.files():
        assert cobertura.file_source(filename) == \
               expected_sources[filename]
github aconrad / pycobertura / tests / test_hunkify_coverage.py View on Github external
def test_hunkify_coverage__2_contiguous_hunks_w_full_context_makes_1_hunk():
    from pycobertura.utils import hunkify_lines
    from pycobertura.cobertura import Line

    lines = [
        Line(1, 'a', None, None),  # context 1
        Line(2, 'b', None, None),  # context 1
        Line(3, 'c', None, None),  # context 1
        Line(4, 'd', True, None),
        Line(5, 'e', None, None),  # context 1
        Line(6, 'f', None, None),  # context 1
        Line(7, 'g', None, None),  # context 1
        Line(8, 'h', None, None),  # context 2
        Line(9, 'i', None, None),  # context 2
        Line(10, 'j', None, None),  # context 2
        Line(11, 'k', False, None),
        Line(12, 'l', None, None),  # context 2
        Line(13, 'm', None, None),  # context 2
        Line(14, 'n', None, None),  # context 2
    ]

    hunks = hunkify_lines(lines)

    assert hunks == [
        [
            Line(1, 'a', None, None),
            Line(2, 'b', None, None),
            Line(3, 'c', None, None),
            Line(4, 'd', True, None),
github aconrad / pycobertura / tests / test_hunkify_coverage.py View on Github external
def test_hunkify_coverage__overlapping():
    from pycobertura.utils import hunkify_lines
    from pycobertura.cobertura import Line

    lines = [
        Line(1, 'a', None, None),
        Line(2, 'b', True, None),
        Line(3, 'c', True, None),
        Line(4, 'd', None, None),
        Line(5, 'e', None, None),
        Line(6, 'f', True, None),
        Line(7, 'g', True, None),
        Line(8, 'h', None, None),
    ]

    hunks = hunkify_lines(lines)

    assert hunks == [
        [
            Line(1, 'a', None, None),
            Line(2, 'b', True, None),
            Line(3, 'c', True, None),
            Line(4, 'd', None, None),
            Line(5, 'e', None, None),
github aconrad / pycobertura / tests / test_hunkify_coverage.py View on Github external
def test_hunkify_coverage__no_valid_hunks_found():
    from pycobertura.utils import hunkify_lines
    from pycobertura.cobertura import Line

    lines = [
        Line(1, 'a', None, None),
        Line(2, 'b', None, None),
        Line(3, 'c', None, None),
        Line(4, 'd', None, None),
        Line(5, 'e', None, None),
        Line(6, 'f', None, None),
        Line(7, 'g', None, None),
        Line(8, 'h', None, None),
        Line(9, 'i', None, None),
    ]

    hunks = hunkify_lines(lines)

    assert hunks == []
github aconrad / pycobertura / tests / test_hunkify_coverage.py View on Github external
Line(15, 'o', None, None),  # context 2
    ]

    hunks = hunkify_lines(lines)

    assert hunks == [
        [
            Line(1, 'a', None, None),
            Line(2, 'b', None, None),
            Line(3, 'c', None, None),
            Line(4, 'd', True, None),
            Line(5, 'e', None, None),
            Line(6, 'f', None, None),
            Line(7, 'g', None, None),
        ], [
            Line(9, 'i', None, None),
            Line(10, 'j', None, None),
            Line(11, 'k', None, None),
            Line(12, 'l', False, None),
            Line(13, 'm', None, None),
            Line(14, 'n', None, None),
            Line(15, 'o', None, None),
        ],
github aconrad / pycobertura / tests / test_hunkify_coverage.py View on Github external
def test_hunkify_coverage__2_contiguous_hunks_w_full_context_makes_1_hunk():
    from pycobertura.utils import hunkify_lines
    from pycobertura.cobertura import Line

    lines = [
        Line(1, 'a', None, None),  # context 1
        Line(2, 'b', None, None),  # context 1
        Line(3, 'c', None, None),  # context 1
        Line(4, 'd', True, None),
        Line(5, 'e', None, None),  # context 1
        Line(6, 'f', None, None),  # context 1
        Line(7, 'g', None, None),  # context 1
        Line(8, 'h', None, None),  # context 2
        Line(9, 'i', None, None),  # context 2
        Line(10, 'j', None, None),  # context 2
        Line(11, 'k', False, None),
        Line(12, 'l', None, None),  # context 2
        Line(13, 'm', None, None),  # context 2
        Line(14, 'n', None, None),  # context 2
    ]

    hunks = hunkify_lines(lines)

    assert hunks == [
        [
            Line(1, 'a', None, None),
            Line(2, 'b', None, None),
            Line(3, 'c', None, None),
            Line(4, 'd', True, None),
            Line(5, 'e', None, None),
github aconrad / pycobertura / tests / test_hunkify_coverage.py View on Github external
def test_hunkify_coverage__no_valid_hunks_found():
    from pycobertura.utils import hunkify_lines
    from pycobertura.cobertura import Line

    lines = [
        Line(1, 'a', None, None),
        Line(2, 'b', None, None),
        Line(3, 'c', None, None),
        Line(4, 'd', None, None),
        Line(5, 'e', None, None),
        Line(6, 'f', None, None),
        Line(7, 'g', None, None),
        Line(8, 'h', None, None),
        Line(9, 'i', None, None),
    ]

    hunks = hunkify_lines(lines)

    assert hunks == []
github aconrad / pycobertura / tests / test_hunkify_coverage.py View on Github external
lines = [
        Line(1, 'a', True, None),
        Line(2, 'b', True, None),
        Line(3, 'c', None, None),
        Line(4, 'd', None, None),
        Line(5, 'e', None, None),
        Line(6, 'f', None, None),
        Line(7, 'g', None, None),
    ]

    hunks = hunkify_lines(lines)

    assert hunks == [
        [
            Line(1, 'a', True, None),
            Line(2, 'b', True, None),
            Line(3, 'c', None, None),
            Line(4, 'd', None, None),
            Line(5, 'e', None, None),
        ],
github aconrad / pycobertura / tests / test_cobertura.py View on Github external
Line(1, 'def foo():\n', True, None),
            Line(2, '    pass\n', True, None),
            Line(3, '\n', None, None),
            Line(4, 'def bar():\n', True, None),
            Line(5, "    a = 'a'\n", False, None),
            Line(6, "    b = 'b'\n", False, None),
        ],
        'dummy/dummy2.py': [
            Line(1, 'def baz():\n', True, None),
            Line(2, '    pass\n', True, None)
        ],
        'dummy/dummy4.py': [
            Line(1, 'def barbaz():\n', False, None),
            Line(2, '    pass\n', False, None),
            Line(3, '\n', None, None),
            Line(4, 'def foobarbaz():\n', False, None),
            Line(5, '    a = 1 + 3\n', False, None),
            Line(6, '    pass\n', False, None)
        ],
    }
    for filename in cobertura.files():
        assert cobertura.file_source(filename) == \
               expected_sources[filename]
github aconrad / pycobertura / tests / test_hunkify_coverage.py View on Github external
def test_hunkify_coverage__2_distant_hunks_w_full_context_makes_2_hunk():
    from pycobertura.utils import hunkify_lines
    from pycobertura.cobertura import Line

    lines = [
        Line(1, 'a', None, None),  # context 1
        Line(2, 'b', None, None),  # context 1
        Line(3, 'c', None, None),  # context 1
        Line(4, 'd', True, None),
        Line(5, 'e', None, None),  # context 1
        Line(6, 'f', None, None),  # context 1
        Line(7, 'g', None, None),  # context 1
        Line(8, 'h', None, None),
        Line(9, 'i', None, None),  # context 2
        Line(10, 'j', None, None),  # context 2
        Line(11, 'k', None, None),  # context 2
        Line(12, 'l', False, None),
        Line(13, 'm', None, None),  # context 2
        Line(14, 'n', None, None),  # context 2
        Line(15, 'o', None, None),  # context 2
    ]

    hunks = hunkify_lines(lines)

    assert hunks == [
        [
            Line(1, 'a', None, None),