How to use the pycobertura.cobertura.CoberturaDiff 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_cobertura_diff.py View on Github external
def test_diff_class_source():
    from pycobertura.cobertura import CoberturaDiff
    from pycobertura.cobertura import Line

    cobertura1 = make_cobertura('tests/dummy.source1/coverage.xml')
    cobertura2 = make_cobertura('tests/dummy.source2/coverage.xml')
    differ = CoberturaDiff(cobertura1, cobertura2)

    expected_sources = {
        'dummy/__init__.py': [],
        'dummy/dummy.py': [
            Line(1, u'def foo():\n', None, None),
            Line(2, u'    pass\n', None, None),
            Line(3, u'\n', None, None),
            Line(4, u'def bar():\n', None, None),
            Line(5, u"    a = 'a'\n", True, 'cov-up'),
            Line(6, u"    d = 'd'\n", True, 'line-edit')
        ],
        'dummy/dummy2.py': [
            Line(1, u'def baz():\n', None, None),
            Line(2, u"    c = 'c'\n", True, 'line-edit'),
            Line(3, u'\n', None, 'line-edit'),
            Line(4, u'def bat():\n', True, 'line-edit'),
github aconrad / pycobertura / tests / test_cobertura_diff.py View on Github external
def test_diff_total_misses_by_class_file():
    from pycobertura.cobertura import CoberturaDiff

    cobertura1 = make_cobertura('tests/dummy.source1/coverage.xml')
    cobertura2 = make_cobertura('tests/dummy.source2/coverage.xml')
    differ = CoberturaDiff(cobertura1, cobertura2)

    expected_sources = {
        'dummy/__init__.py': 0,
        'dummy/dummy.py': -2,
        'dummy/dummy2.py': 1,
        'dummy/dummy3.py': 2,
    }

    for filename in cobertura2.files():
        assert differ.diff_total_misses(filename) == \
            expected_sources[filename]
github aconrad / pycobertura / tests / test_cobertura_diff.py View on Github external
def test_diff_total_hits_by_class_file():
    from pycobertura.cobertura import CoberturaDiff

    cobertura1 = make_cobertura('tests/dummy.source1/coverage.xml')
    cobertura2 = make_cobertura('tests/dummy.source2/coverage.xml')
    differ = CoberturaDiff(cobertura1, cobertura2)

    expected_total_hits = {
        'dummy/__init__.py': 0,
        'dummy/dummy.py': 2,
        'dummy/dummy2.py': 1,
        'dummy/dummy3.py': 0,
    }

    for filename in cobertura2.files():
        assert differ.diff_total_hits(filename) == \
            expected_total_hits[filename]
github aconrad / pycobertura / tests / test_cobertura_diff.py View on Github external
def test_diff__has_all_changes_covered__some_changed_code_is_still_uncovered():
    from pycobertura.cobertura import Cobertura, CoberturaDiff

    cobertura1 = Cobertura('tests/dummy.zeroexit1/coverage.xml')
    cobertura2 = Cobertura('tests/dummy.zeroexit2/coverage.xml')
    differ = CoberturaDiff(cobertura1, cobertura2)
    assert differ.has_all_changes_covered() is False
github aconrad / pycobertura / tests / test_cobertura_diff.py View on Github external
def test_diff__has_not_better_coverage():
    from pycobertura.cobertura import Cobertura, CoberturaDiff

    cobertura1 = Cobertura('tests/dummy.zeroexit2/coverage.xml')
    cobertura2 = Cobertura('tests/dummy.zeroexit1/coverage.xml')
    differ = CoberturaDiff(cobertura1, cobertura2)
    assert differ.has_better_coverage() is False
github aconrad / pycobertura / tests / test_cobertura_diff.py View on Github external
def test_diff_line_rate():
    from pycobertura.cobertura import CoberturaDiff

    cobertura1 = make_cobertura('tests/dummy.source1/coverage.xml')
    cobertura2 = make_cobertura('tests/dummy.source2/coverage.xml')
    differ = CoberturaDiff(cobertura1, cobertura2)

    assert differ.diff_line_rate() == 0.31059999999999993
github aconrad / pycobertura / tests / test_cobertura_diff.py View on Github external
def test_diff__has_better_coverage():
    from pycobertura.cobertura import Cobertura, CoberturaDiff

    cobertura1 = Cobertura('tests/dummy.zeroexit1/coverage.xml')
    cobertura2 = Cobertura('tests/dummy.zeroexit2/coverage.xml')
    differ = CoberturaDiff(cobertura1, cobertura2)
    assert differ.has_better_coverage() is True
github aconrad / pycobertura / tests / test_cobertura_diff.py View on Github external
def test_diff_line_rate_by_class_file():
    from pycobertura.cobertura import CoberturaDiff

    cobertura1 = make_cobertura('tests/dummy.source1/coverage.xml')
    cobertura2 = make_cobertura('tests/dummy.source2/coverage.xml')
    differ = CoberturaDiff(cobertura1, cobertura2)

    expected_sources = {
        'dummy/__init__.py': 0,
        'dummy/dummy.py': 0.4,
        'dummy/dummy2.py': -0.25,
        'dummy/dummy3.py': 0.0,
    }

    for filename in cobertura2.files():
        assert differ.diff_line_rate(filename) == \
            expected_sources[filename]
github aconrad / pycobertura / tests / test_cobertura_diff.py View on Github external
def test_diff_total_misses():
    from pycobertura.cobertura import CoberturaDiff

    cobertura1 = make_cobertura('tests/dummy.source1/coverage.xml')
    cobertura2 = make_cobertura('tests/dummy.source2/coverage.xml')
    differ = CoberturaDiff(cobertura1, cobertura2)

    assert differ.diff_total_misses() == 1
github aconrad / pycobertura / pycobertura / reporters.py View on Github external
def __init__(self, cobertura1, cobertura2, show_source=True):
        self.differ = CoberturaDiff(cobertura1, cobertura2)
        self.show_source = show_source