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]
def test_tested_unlisted(covtest): covtest.makefile(""" def func(): pass """) covtest.run() expected = check_coverage.Message( check_coverage.MsgType.perfect_file, 'module.py', 'module.py has 100% coverage but is not in perfect_files!') assert covtest.check(perfect_files=[]) == [expected]
def test_untested(covtest): covtest.makefile(""" def func(): pass def untested(): pass """) covtest.run() expected = check_coverage.Message( check_coverage.MsgType.insufficient_coverage, 'module.py', 'module.py has 75.00% line and 100.00% branch coverage!') assert covtest.check() == [expected]
def test_untested_branches(covtest): covtest.makefile(""" def func2(arg): if arg: pass else: pass def func(): func2(True) """) covtest.run() expected = check_coverage.Message( check_coverage.MsgType.insufficient_coverage, 'module.py', 'module.py has 100.00% line and 50.00% branch coverage!') assert covtest.check() == [expected]
def test_untested_branches(covtest): covtest.makefile(""" def func2(arg): if arg: pass else: pass def func(): func2(True) """) covtest.run() line_coverage = "83.33%" if sys.version_info[:2] >= (3, 10) else "100.00%" expected = check_coverage.Message( check_coverage.MsgType.insufficient_coverage, 'module.py', f'module.py has {line_coverage} line and 50.00% branch coverage!') assert covtest.check() == [expected]