Skip to content

Commit

Permalink
Setup PyTest with test coverage (lucivpav#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
derpferd authored and lucivpav committed Sep 24, 2019
1 parent 971df09 commit bb7dfa6
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 14 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PYTHONPATH=./src
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ makemeahanzi
cedict
tagmanager
__pycache__
backend/.coverage
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ install:
- make

script:
- make test
- make test

after_success:
- (cd backend; codecov)
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
init: setup
pip install pipenv
pip install codecov
pipenv install
pipenv install --dev

setup:
./setup.sh

test:
(cd backend; pipenv run python -m unittest discover)
(export PYTHONPATH=$$PYTHONPATH:src; cd backend; pipenv run pytest test)
(export PYTHONPATH=$$PYTHONPATH:src; cd backend; pipenv run pytest test --cov ./src)
3 changes: 3 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ flask = "*"
flask-restful = "*"
flask-jsonpify = "*"
flask-cors = "*"
pytest = "*"
pytest-mock = "*"
pytest-cov = "*"

[requires]
python_version = "3.7"
140 changes: 136 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ gen.py --makemeahanzi=$MAKEMEAHANZI_PATH --title='Vocabulary' --guide='star' --s

## Running tests
```
pipenv install
cd backend
python3 -m unittest discover
pipenv run pytest test
```

## License
Expand Down
Empty file removed backend/__init__.py
Empty file.
3 changes: 0 additions & 3 deletions backend/test/test_gen.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), \
'../src')));
import unittest
import tempfile

Expand Down
4 changes: 0 additions & 4 deletions backend/test/test_word_manager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), \
'../src')));
import unittest
from word_manager import WordManager, Word
from exceptions import GenException
Expand Down

0 comments on commit bb7dfa6

Please sign in to comment.