Skip to content

Commit 2f2f790

Browse files
Chapter 10 - Recipe 'Determining test coverage'
Python3 changes
1 parent fd14857 commit 2f2f790

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Diff for: test_app.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
from unittest import mock
55
import tempfile
66
import geoip2.records
7+
import coverage
8+
9+
cov = coverage.coverage(
10+
omit = [
11+
'/Users/shalabh.aggarwal/workspace/cookbook10/lib/python3.6/site-packages/*',
12+
'app_tests.py'
13+
]
14+
)
15+
cov.start()
716

817

918
class CatalogTestCase(unittest.TestCase):
@@ -147,4 +156,11 @@ def test_search_product(self):
147156

148157

149158
if __name__ == '__main__':
150-
unittest.main()
159+
try:
160+
unittest.main()
161+
finally:
162+
cov.stop()
163+
cov.save()
164+
cov.report()
165+
cov.html_report(directory = 'coverage')
166+
cov.erase()

0 commit comments

Comments
 (0)