Skip to content

Commit

Permalink
Add Coverage.py and codecov functionality (#219)
Browse files Browse the repository at this point in the history
* Add Coverage.py and codecov functionality
* Fix check command
* Fix unit test error
* Update coverage command, update travis
* Temporarily allow failures on 3.4 and 3.5
  • Loading branch information
rogebrd authored Sep 1, 2020
1 parent c2d568d commit 0646925
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
branch = True
source = dropbox/
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Coverage Files
.coverage
coverage.xml

# Generic Python files
/.cache/
/.eggs/
/.idea/
Expand All @@ -12,6 +17,8 @@ __pycache__/
*.pyc
*.pyo
*~

# Virtual Environments
.venv
venv/
venv3/
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: python

language:
python
python:
- "2.7"
- pypy
Expand All @@ -9,15 +9,13 @@ python:
- "3.7"
- "3.8"
- pypy3

install:
- pip install tox-travis

matrix:
allow_failures:
# PyPy 3k probably won't work until it acquires compatibility with
# >= 3.4
- python: pypy3

- python: "3.4"
- python: "3.5"
script:
- tox
after_success:
- bash <(curl -s https://codecov.io/bash)
2 changes: 1 addition & 1 deletion test/test_dropbox_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_NoRedirect_whole_flow(self, auth_flow_offline_with_scopes):
auth_flow_offline_with_scopes.requests_session.post.assert_called_once()
token_call_args = auth_flow_offline_with_scopes.requests_session.post.call_args_list
assert len(token_call_args) == 1
first_call_args = token_call_args[0]._get_call_arguments()
first_call_args = token_call_args[0]
assert first_call_args[0][0] == 'https://{}/oauth2/token'.format(session.API_HOST)
call_data = first_call_args[1]['data']
assert call_data['client_id'] == APP_KEY
Expand Down
67 changes: 45 additions & 22 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[tox]

envlist = py{27,34,35,36,37,38,py,py3},check,lint
envlist = py{27,34,35,36,37,38,py,py3},check,lint,docs,test_unit,coverage,codecov
skip_missing_interpreters = true

[tox:travis]

2.7 = lint
pypy = lint
3.4 = lint
3.5 = lint
3.6 = check, lint
3.7 = check, lint
3.8 = check, lint
pypy3 = lint
2.7 = check, lint, docs, test_unit
pypy = check, lint, docs, test_unit
3.4 = check, lint, docs, test_unit
3.5 = check, lint, docs, test_unit
3.6 = check, lint, docs, test_unit
3.7 = check, lint, docs, test_unit, coverage, codecov
3.8 = check, lint, docs, test_unit, coverage, codecov
pypy3 = check, lint, docs, test_unit


[flake8]
Expand All @@ -22,7 +22,7 @@ ignore = E128,E301,E302,E305,E402,W503,W504
max-line-length = 100


[testenv]
[testenv:test_integration]

commands =
pytest {posargs}
Expand All @@ -37,34 +37,57 @@ passenv =
DROPBOX_WEB_HOST

deps =
pip
-rtest/requirements.txt

[testenv:check]

commands =
python setup.py check -m -r -s -v
python setup.py sdist bdist_wheel
twine check dist/*

deps =
Pygments
docutils
twine

usedevelop = true


[testenv:lint]

description = format the code base to adhere to our styles, and complain about what we cannot do automatically
commands =
flake8 setup.py dropbox example test
pylint --rcfile=.pylintrc setup.py dropbox \
example/back-up-and-restore/backup-and-restore-example.py \
example/updown.py \
test/test_dropbox.py
deps =
flake8
# Needed to support Python 3.6
pylint >= 1.7.0
# This probably breaks on Windows. See
# <https://github.com/tox-dev/tox/issues/384>.
-rtest/requirements.txt

usedevelop = true

[testenv:coverage]

commands =
coverage run --rcfile=.coveragerc -m pytest test/test_dropbox_unit.py
coverage xml

deps =
-rtest/requirements.txt
coverage

[testenv:test_unit]

commands =
pytest test/test_dropbox_unit.py

deps =
-rtest/requirements.txt

[testenv:docs]
description = invoke sphinx-build to build the HTML docs
extras = docs
commands = sphinx-build -b html docs build/html
deps =
sphinx

[testenv:codecov]
passenv = CI TRAVIS TRAVIS_*
deps = codecov
commands = codecov

0 comments on commit 0646925

Please sign in to comment.