only run coverage for relevant test (#818)

* fix test troubles

* another try

* testing travis build?

* trying pytestmark
This commit is contained in:
Eldinnie 2017-09-09 23:37:07 +02:00 committed by GitHub
parent e39b6abe61
commit 4fe4eea893
2 changed files with 13 additions and 8 deletions

View file

@ -24,14 +24,15 @@ before_cache:
- rm -f $HOME/.pre-commit/pre-commit.log
install:
- pip install coveralls pytest-cov
- pip install -U coveralls pytest-cov
- pip install -U wheel
- pip install -U -r requirements.txt
- pip install -U -r requirements-dev.txt
- if [[ $TRAVIS_PYTHON_VERSION != 'pypy'* ]]; then pip install ujson; fi
script:
- pytest -v --cov=telegram
- pytest -v -m nocoverage
- pytest -v -m "not nocoverage" --cov
after_success:
- coverage combine

View file

@ -17,7 +17,6 @@
# You should have received a copy of the GNU Lesser Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
import os
import subprocess
import sys
from platform import python_implementation
@ -26,17 +25,22 @@ import pytest
def call_pre_commit_hook(hook_id):
__tracebackhide__ = True
return os.system(' '.join(['pre-commit', 'run', '--all-files', hook_id]))
return os.system(' '.join(['pre-commit', 'run', '--all-files', hook_id])) # pragma: no cover
@pytest.mark.nocoverage
@pytest.mark.parametrize('hook_id', argvalues=('yapf', 'flake8', 'pylint'))
@pytest.mark.skipif(not os.getenv('TRAVIS'), reason='Not running in travis.')
@pytest.mark.skipif(not sys.version_info[:2] == (3, 6) or python_implementation() != 'CPython',
reason='Only running pre-commit-hooks on newest tested python version, '
'as they are slow and consistent across platforms.')
reason='Only running pre-commit-hooks on newest tested python version, '
'as they are slow and consistent across platforms.')
def test_pre_commit_hook(hook_id):
assert call_pre_commit_hook(hook_id) == 0
assert call_pre_commit_hook(hook_id) == 0 # pragma: no cover
@pytest.mark.nocoverage
@pytest.mark.skipif(
not sys.version_info[:2] in ((3, 6), (2, 7)) or python_implementation() != 'CPython',
reason='Only testing build on 2.7 and 3.6')
def test_build():
assert os.system('python setup.py bdist_dumb') == 0
assert os.system('python setup.py bdist_dumb') == 0 # pragma: no cover