3
3
4
4
"""Test LCOV-based summary reporting for coverage.py."""
5
5
6
+ import math
6
7
import textwrap
7
8
8
9
from tests .coveragetest import CoverageTest
@@ -75,7 +76,8 @@ def IsItTrue():
75
76
self .assert_doesnt_exist (".coverage" )
76
77
cov = coverage .Coverage (source = ["." ])
77
78
self .start_import_stop (cov , "main_file" )
78
- cov .lcov_report ()
79
+ pct = cov .lcov_report ()
80
+ assert pct == 50.0
79
81
actual_result = self .get_lcov_report_content ()
80
82
assert expected_result == actual_result
81
83
@@ -87,7 +89,8 @@ def test_simple_line_coverage_two_files(self):
87
89
self .make_file (".coveragerc" , "[lcov]\n output = data.lcov\n " )
88
90
cov = coverage .Coverage (source = "." )
89
91
self .start_import_stop (cov , "test_file" )
90
- cov .lcov_report ()
92
+ pct = cov .lcov_report ()
93
+ assert pct == 50.0
91
94
self .assert_exists ("data.lcov" )
92
95
expected_result = textwrap .dedent ("""\
93
96
TN:
@@ -130,7 +133,8 @@ def is_it_x(x):
130
133
self .assert_doesnt_exist (".coverage" )
131
134
cov = coverage .Coverage (branch = True , source = "." )
132
135
self .start_import_stop (cov , "main_file" )
133
- cov .lcov_report ()
136
+ pct = cov .lcov_report ()
137
+ assert math .isclose (pct , 16.666666666666668 )
134
138
self .assert_exists ("coverage.lcov" )
135
139
expected_result = textwrap .dedent ("""\
136
140
TN:
@@ -177,7 +181,8 @@ def test_is_it_x(self):
177
181
self .assert_doesnt_exist (".coverage" )
178
182
cov = coverage .Coverage (branch = True , source = "." )
179
183
self .start_import_stop (cov , "test_file" )
180
- cov .lcov_report ()
184
+ pct = cov .lcov_report ()
185
+ assert math .isclose (pct , 41.666666666666664 )
181
186
self .assert_exists ("coverage.lcov" )
182
187
expected_result = textwrap .dedent ("""\
183
188
TN:
@@ -225,7 +230,8 @@ def test_half_covered_branch(self):
225
230
self .assert_doesnt_exist (".coverage" )
226
231
cov = coverage .Coverage (branch = True , source = "." )
227
232
self .start_import_stop (cov , "main_file" )
228
- cov .lcov_report ()
233
+ pct = cov .lcov_report ()
234
+ assert math .isclose (pct , 66.66666666666667 )
229
235
self .assert_exists ("coverage.lcov" )
230
236
expected_result = textwrap .dedent ("""\
231
237
TN:
@@ -259,7 +265,8 @@ def test_empty_init_files(self):
259
265
self .assert_doesnt_exist (".coverage" )
260
266
cov = coverage .Coverage (branch = True , source = "." )
261
267
self .start_import_stop (cov , "__init__" )
262
- cov .lcov_report ()
268
+ pct = cov .lcov_report ()
269
+ assert pct == 0.0
263
270
self .assert_exists ("coverage.lcov" )
264
271
# Newer Pythons have truly empty empty files.
265
272
if env .PYBEHAVIOR .empty_is_empty :
0 commit comments