How to use the pycobertura.utils.hunkify_lines function in pycobertura

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_hunkify_coverage.py View on Github external
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
def test_hunkify_coverage__top():
    from pycobertura.utils import hunkify_lines
    from pycobertura.cobertura import Line

    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_hunkify_coverage.py View on Github external
def test_hunkify_coverage__bottom():
    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', True, None),
        Line(7, 'g', True, None),
    ]

    hunks = hunkify_lines(lines)

    assert hunks == [
        [
            Line(3, 'c', None, None),
            Line(4, 'd', None, None),
            Line(5, 'e', None, None),
            Line(6, 'f', True, None),
            Line(7, 'g', True, None),
        ],
github aconrad / pycobertura / tests / test_hunkify_coverage.py View on Github external
def test_hunkify_coverage__middle():
    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', False, None),
        Line(5, 'e', False, None),
        Line(6, 'f', None, None),
        Line(7, 'g', None, None),
        Line(8, 'h', None, None),
    ]

    hunks = hunkify_lines(lines)

    assert hunks == [
        [
            Line(1, 'a', None, None),
            Line(2, 'b', None, None),
            Line(3, 'c', None, None),
            Line(4, 'd', False, None),
            Line(5, 'e', False, None),
            Line(6, 'f', None, None),
            Line(7, 'g', None, None),
            Line(8, 'h', None, None),
        ],
github aconrad / pycobertura / tests / test_hunkify_coverage.py View on Github external
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),
            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),
github aconrad / pycobertura / tests / test_hunkify_coverage.py View on Github external
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),
            Line(6, 'f', None, None),
            Line(7, 'g', None, None),
            Line(8, 'h', None, None),
            Line(9, 'i', None, None),
            Line(10, 'j', None, None),
            Line(11, 'k', False, None),
            Line(12, 'l', None, None),
            Line(13, 'm', None, 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),
            Line(6, 'f', True, None),
            Line(7, 'g', True, None),
            Line(8, 'h', None, None),
        ],
github aconrad / pycobertura / pycobertura / cobertura.py View on Github external
def file_source_hunks(self, filename):
        """
        Like `CoberturaDiff.file_source`, but returns a list of line hunks of
        the lines that have changed for the given file `filename`. An empty
        list means that the file has no lines that have a change in coverage
        status.
        """
        lines = self.file_source(filename)
        hunks = hunkify_lines(lines)
        return hunks