diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index bcc99c18f..000000000 --- a/.coveragerc +++ /dev/null @@ -1,10 +0,0 @@ -[report] -omit = - */pyshared/* - */python?.?/* - */test/* -exclude_lines = - assert False - raise NotImplementedError - if __name__ == .__main__.: - def __repr__ diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f109f2e23..4e463af7c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -49,10 +49,11 @@ jobs: run: | tox -e py-test - - name: Test latest Python version with tox and get coverage - if: matrix.python-version == '3.x' + - name: Upload code coverage + if: matrix.python-version == '3.7' && matrix.platform == 'ubuntu-latest' run: | - tox -vv -e py-cov + pip install codecov || true + codecov || true - name: Test latest Python version with tox and mypy if: matrix.python-version == '3.x' @@ -63,12 +64,6 @@ jobs: run: | tox -vv -e py-mypy - - name: Upload code coverage - if: matrix.python-version == '3.x' - run: | - pip install codecov || true - codecov || true - test-docs: runs-on: ubuntu-latest diff --git a/setup.cfg b/setup.cfg index 344c457e0..c8bd6f21c 100644 --- a/setup.cfg +++ b/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] min-version = 3.6 accept-encodings = utf-8 diff --git a/setup.py b/setup.py index 62bac6e4e..c69b703f8 100755 --- a/setup.py +++ b/setup.py @@ -103,11 +103,11 @@ setup( extras_require={ "test": [ "beautifulsoup4", - "coverage", "flask", "mock", "pylast", "pytest", + "pytest-cov", "python-mpd2", "python3-discogs-client>=2.3.15", "py7zr", diff --git a/tox.ini b/tox.ini index 22d85a8c7..e650e3aec 100644 --- a/tox.ini +++ b/tox.ini @@ -25,8 +25,7 @@ deps = mypy: {[_mypy]deps} passenv = INTEGRATION_TEST commands = - test: python -bb -m pytest -rs {posargs} - cov: coverage run -m pytest -rs {posargs} + test: python -m pytest {posargs} lint: python -m flake8 {posargs} {[_lint]files} mypy: mypy -p beets -p beetsplug mypy: mypy test