mirror of
https://github.com/beetbox/beets.git
synced 2025-12-09 10:05:35 +01:00
Add pytest and coverage configuration
Add `pytest-cov` which automatically measures coverage while tests are
executing and update tox and ci build configuration accordingly.
Add configuration for coverage:
1. Enable analysing logical branches
2. Save coverage details as HTML for local development use
3. Configure the HTML output to include coverage context: on the
right-hand side of each covered code line there is an expandable
section which lists every test that ran that line.
This commit is contained in:
parent
34a59f98b3
commit
8b4983fe7c
5 changed files with 46 additions and 22 deletions
10
.coveragerc
10
.coveragerc
|
|
@ -1,10 +0,0 @@
|
||||||
[report]
|
|
||||||
omit =
|
|
||||||
*/pyshared/*
|
|
||||||
*/python?.?/*
|
|
||||||
*/test/*
|
|
||||||
exclude_lines =
|
|
||||||
assert False
|
|
||||||
raise NotImplementedError
|
|
||||||
if __name__ == .__main__.:
|
|
||||||
def __repr__
|
|
||||||
13
.github/workflows/ci.yaml
vendored
13
.github/workflows/ci.yaml
vendored
|
|
@ -49,10 +49,11 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
tox -e py-test
|
tox -e py-test
|
||||||
|
|
||||||
- name: Test latest Python version with tox and get coverage
|
- name: Upload code coverage
|
||||||
if: matrix.python-version == '3.x'
|
if: matrix.python-version == '3.7' && matrix.platform == 'ubuntu-latest'
|
||||||
run: |
|
run: |
|
||||||
tox -vv -e py-cov
|
pip install codecov || true
|
||||||
|
codecov || true
|
||||||
|
|
||||||
- name: Test latest Python version with tox and mypy
|
- name: Test latest Python version with tox and mypy
|
||||||
if: matrix.python-version == '3.x'
|
if: matrix.python-version == '3.x'
|
||||||
|
|
@ -63,12 +64,6 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
tox -vv -e py-mypy
|
tox -vv -e py-mypy
|
||||||
|
|
||||||
- name: Upload code coverage
|
|
||||||
if: matrix.python-version == '3.x'
|
|
||||||
run: |
|
|
||||||
pip install codecov || true
|
|
||||||
codecov || true
|
|
||||||
|
|
||||||
test-docs:
|
test-docs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
|
|
||||||
40
setup.cfg
40
setup.cfg
|
|
@ -1,3 +1,43 @@
|
||||||
|
[tool:pytest]
|
||||||
|
# do not litter the working directory
|
||||||
|
cache_dir = /tmp/pytest_cache
|
||||||
|
# slightly more verbose output
|
||||||
|
console_output_style = count
|
||||||
|
addopts =
|
||||||
|
# show all skipped/failed/xfailed tests in the summary except passed
|
||||||
|
-ra
|
||||||
|
--strict-config
|
||||||
|
# record coverage in these two packages
|
||||||
|
--cov=beets
|
||||||
|
--cov=beetsplug
|
||||||
|
# save xml for coverage upload
|
||||||
|
--cov-report=xml:.reports/coverage.xml
|
||||||
|
# save html files for local dev use
|
||||||
|
--cov-report=html:.reports/html
|
||||||
|
# record coverage across logical branches
|
||||||
|
--cov-branch
|
||||||
|
# show which tests cover specific lines in the code (available in HTML)
|
||||||
|
--cov-context=test
|
||||||
|
|
||||||
|
[coverage:run]
|
||||||
|
data_file = .reports/coverage/data
|
||||||
|
branch = true
|
||||||
|
relative_files = true
|
||||||
|
|
||||||
|
[coverage:report]
|
||||||
|
precision = 2
|
||||||
|
skip_empty = true
|
||||||
|
show_missing = true
|
||||||
|
exclude_lines =
|
||||||
|
pragma: no cover
|
||||||
|
if TYPE_CHECKING
|
||||||
|
if typing.TYPE_CHECKING
|
||||||
|
raise AssertionError
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
[coverage:html]
|
||||||
|
show_contexts = true
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
min-version = 3.6
|
min-version = 3.6
|
||||||
accept-encodings = utf-8
|
accept-encodings = utf-8
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -103,11 +103,11 @@ setup(
|
||||||
extras_require={
|
extras_require={
|
||||||
"test": [
|
"test": [
|
||||||
"beautifulsoup4",
|
"beautifulsoup4",
|
||||||
"coverage",
|
|
||||||
"flask",
|
"flask",
|
||||||
"mock",
|
"mock",
|
||||||
"pylast",
|
"pylast",
|
||||||
"pytest",
|
"pytest",
|
||||||
|
"pytest-cov",
|
||||||
"python-mpd2",
|
"python-mpd2",
|
||||||
"python3-discogs-client>=2.3.15",
|
"python3-discogs-client>=2.3.15",
|
||||||
"py7zr",
|
"py7zr",
|
||||||
|
|
|
||||||
3
tox.ini
3
tox.ini
|
|
@ -25,8 +25,7 @@ deps =
|
||||||
mypy: {[_mypy]deps}
|
mypy: {[_mypy]deps}
|
||||||
passenv = INTEGRATION_TEST
|
passenv = INTEGRATION_TEST
|
||||||
commands =
|
commands =
|
||||||
test: python -bb -m pytest -rs {posargs}
|
test: python -m pytest {posargs}
|
||||||
cov: coverage run -m pytest -rs {posargs}
|
|
||||||
lint: python -m flake8 {posargs} {[_lint]files}
|
lint: python -m flake8 {posargs} {[_lint]files}
|
||||||
mypy: mypy -p beets -p beetsplug
|
mypy: mypy -p beets -p beetsplug
|
||||||
mypy: mypy test
|
mypy: mypy test
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue