Skip to content

Commit

Permalink
Configure pytest to run tests and coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
rhcarvalho committed Feb 20, 2017
1 parent 95f11aa commit fbc8d14
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
15 changes: 14 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
[run]
omit=
branch = True
omit =
*/lib/python*/site-packages/*
*/lib/python*/*
/usr/*
setup.py
# TODO(rhcarvalho): this is used to ignore test files from coverage report.
# We can make this less generic when we stick with a single test pattern in
# the repo.
test_*.py
*_tests.py

[report]
fail_under = 25

[html]
directory = cover
6 changes: 6 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""pytest configuration"""


def pytest_ignore_collect(path):
"""Hook to ignore symlink files and directories."""
return path.islink()
19 changes: 19 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,22 @@ lint_disable=fixme,locally-disabled,file-ignored,duplicate-code
exclude=.tox/*,utils/*,inventory/*
max_line_length = 120
ignore = E501,T003

[tool:pytest]
norecursedirs =
.*
__pycache__
cover
docs
# utils have its own config
utils
python_files =
# TODO(rhcarvalho): rename test files to follow a single pattern. "test*.py"
# is Python unittest's default, while pytest discovers both "test_*.py" and
# "*_test.py" by default.
test_*.py
*_tests.py
addopts =
--cov=.
--cov-report=term
--cov-report=html
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ nose
coverage
mock
pytest
pytest-cov
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ commands =
yamllint: python setup.py yamllint
unit: nosetests
generate_validation: python setup.py generate_validation


0 comments on commit fbc8d14

Please sign in to comment.