This commit is contained in:
Waylon Walker 2022-03-31 20:20:07 -05:00
commit 38355d2442
No known key found for this signature in database
GPG key ID: 66E2BF2B4190EFE4
9083 changed files with 1225834 additions and 0 deletions

View file

@ -0,0 +1,40 @@
"""Test cases for reports generated by mypy."""
import textwrap
from mypy.test.helpers import Suite, assert_equal
from mypy.report import CoberturaPackage, get_line_rate
class CoberturaReportSuite(Suite):
def test_get_line_rate(self) -> None:
assert_equal('1.0', get_line_rate(0, 0))
assert_equal('0.3333', get_line_rate(1, 3))
def test_as_xml(self) -> None:
import lxml.etree as etree # type: ignore
cobertura_package = CoberturaPackage('foobar')
cobertura_package.covered_lines = 21
cobertura_package.total_lines = 42
child_package = CoberturaPackage('raz')
child_package.covered_lines = 10
child_package.total_lines = 10
child_package.classes['class'] = etree.Element('class')
cobertura_package.packages['raz'] = child_package
expected_output = textwrap.dedent('''\
<package complexity="1.0" name="foobar" branch-rate="0" line-rate="0.5000">
<classes/>
<packages>
<package complexity="1.0" name="raz" branch-rate="0" line-rate="1.0000">
<classes>
<class/>
</classes>
</package>
</packages>
</package>
''').encode('ascii')
assert_equal(expected_output,
etree.tostring(cobertura_package.as_xml(), pretty_print=True))