File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 11Dockerfile-dev
2- Dockerfile-prod
2+ Dockerfile-prod
3+ venv
Original file line number Diff line number Diff line change 1- import unittest
1+ import unittest , coverage
22from flask .cli import FlaskGroup
33from project import create_app , db
44from project .api .models import User
55
6+
7+ COV = coverage .coverage (
8+ branch = True ,
9+ include = "project/*" ,
10+ omit = [
11+ "project/test/*" ,
12+ "project/config.py" ,
13+ ],
14+ )
15+
16+ COV .start ()
17+
618app = create_app ()
719cli = FlaskGroup (create_app = create_app )
820
@@ -32,5 +44,23 @@ def seed_db():
3244 db .session .commit ()
3345
3446
47+ @cli .command ()
48+ def cov ():
49+ """
50+ Runs the unit tests coverage
51+ """
52+ tests = unittest .TestLoader ().discover ("project/tests" )
53+ result = unittest .TextTestRunner (verbosity = 2 ).run (tests )
54+ if result .wasSuccessful ():
55+ COV .stop ()
56+ COV .save ()
57+ print ("Coverage Summary:" )
58+ COV .report ()
59+ COV .html_report ()
60+ COV .erase ()
61+ return 0
62+ return 1
63+
64+
3565if __name__ == "__main__" :
3666 cli ()
Original file line number Diff line number Diff line change @@ -13,3 +13,4 @@ SQLAlchemy==2.0.4
1313typing-extensions == 4.5.0
1414Werkzeug == 2.2.3
1515zipp == 3.15.0
16+ coverage == 7.2.1
You can’t perform that action at this time.
0 commit comments