Skip to content

Commit f5965f3

Browse files
Adds, pytest support (#6)
* Adds, coverage report data * Adds, coverage support * Adds, pytest support * Adds, codecov support * Removes, coverage.xml
1 parent 621d92e commit f5965f3

File tree

7 files changed

+19
-24
lines changed

7 files changed

+19
-24
lines changed

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[run]
2+
omit = app/test/*

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
FLASK_ENV=xxxx
2-
FLASK_DEBUG=xxxx
2+
FLASK_DEBUG=xxxx
3+
CODECOV_TOKEN=xxxx

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
__pycache__/
22
.pip.cache/
3+
.pytest.cache/
34
.vscode/
45
env/
6+
htmlcov/
57

6-
.env
8+
.DS_Store
9+
.env
10+
.coverage
11+
coverage.xml

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ script:
2424
- safety check --full-report --file requirements/dev.txt
2525
- safety check --full-report --file requirements/test.txt
2626
- pylint --rcfile .pylintrc manage.py app
27-
- python manage.py test
27+
- pytest --cov-config=.coveragerc --cov-report xml --cov app app/test
28+
29+
after_success:
30+
- codecov

app/test/test_config.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"""
22
Tests the app.main.config module.
33
"""
4-
import unittest
5-
64
from flask import current_app
75
from flask_testing import TestCase
86

@@ -146,7 +144,3 @@ def test_app_is_production(self):
146144
defined config are set or not.
147145
"""
148146
self.assertTrue(app.config.get("JSONIFY_PRETTYPRINT_REGULAR"))
149-
150-
151-
if __name__ == "__main__":
152-
unittest.main()

manage.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Application entry point
33
"""
44
import os
5-
import unittest
65

76
from flask_cors import CORS
87
from flask_script import Manager
@@ -29,19 +28,5 @@ def run():
2928
app.run()
3029

3130

32-
@manager.command
33-
def test():
34-
"""
35-
Runs the unit tests.
36-
37-
$ python manage.py test
38-
"""
39-
tests = unittest.TestLoader().discover("app/test", pattern="test*.py")
40-
result = unittest.TextTestRunner(verbosity=2).run(tests)
41-
if result.wasSuccessful():
42-
return 0
43-
return 1
44-
45-
4631
if __name__ == "__main__":
4732
manager.run()

requirements/test.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,10 @@ safety==1.8.5
66
# For static analysis
77
pylint==2.4.1
88

9+
# For code coverage reporting
10+
pytest==5.1.3
11+
pytest-cov==2.7.1
12+
codecov==2.0.15
13+
914
# For testing
1015
Flask-Testing==0.7.1

0 commit comments

Comments
 (0)