check_coverage: Truncate long floats
This commit is contained in:
parent
c5c566aadc
commit
4da9b8c495
@ -239,7 +239,7 @@ def check(fileobj, perfect_files):
|
||||
is_bad = line_cov < 100 or branch_cov < 100
|
||||
|
||||
if filename in perfect_src_files and is_bad:
|
||||
text = "{} has {}% line and {}% branch coverage!".format(
|
||||
text = "{} has {:.2f}% line and {:.2f}% branch coverage!".format(
|
||||
filename, line_cov, branch_cov)
|
||||
messages.append(Message(MsgType.insufficent_coverage, filename,
|
||||
text))
|
||||
|
@ -131,7 +131,36 @@ def test_untested(covtest):
|
||||
expected = check_coverage.Message(
|
||||
check_coverage.MsgType.insufficent_coverage,
|
||||
'module.py',
|
||||
'module.py has 75.0% line and 100.0% branch coverage!')
|
||||
'module.py has 75.00% line and 100.00% branch coverage!')
|
||||
assert covtest.check() == [expected]
|
||||
|
||||
|
||||
def test_untested_floats(covtest):
|
||||
"""Make sure we don't report 58.330000000000005% coverage."""
|
||||
covtest.makefile("""
|
||||
def func():
|
||||
pass
|
||||
|
||||
def untested():
|
||||
pass
|
||||
|
||||
def untested2():
|
||||
pass
|
||||
|
||||
def untested3():
|
||||
pass
|
||||
|
||||
def untested4():
|
||||
pass
|
||||
|
||||
def untested5():
|
||||
pass
|
||||
""")
|
||||
covtest.run()
|
||||
expected = check_coverage.Message(
|
||||
check_coverage.MsgType.insufficent_coverage,
|
||||
'module.py',
|
||||
'module.py has 58.33% line and 100.00% branch coverage!')
|
||||
assert covtest.check() == [expected]
|
||||
|
||||
|
||||
@ -150,7 +179,7 @@ def test_untested_branches(covtest):
|
||||
expected = check_coverage.Message(
|
||||
check_coverage.MsgType.insufficent_coverage,
|
||||
'module.py',
|
||||
'module.py has 100.0% line and 50.0% branch coverage!')
|
||||
'module.py has 100.00% line and 50.00% branch coverage!')
|
||||
assert covtest.check() == [expected]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user