From 93b5047ec5050d63c10a6fe16a09b671a7a03df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionel=20Cristian=20M=C4=83rie=C8=99?= Date: Tue, 19 Mar 2024 03:07:39 +0200 Subject: [PATCH] Add test for pyproject.toml loading without explicit --cov-config. Ref #508. --- tests/test_pytest_cov.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_pytest_cov.py b/tests/test_pytest_cov.py index 2049ef7..bd9df38 100644 --- a/tests/test_pytest_cov.py +++ b/tests/test_pytest_cov.py @@ -1365,6 +1365,13 @@ def test_basic(no_cover): exclude_lines = raise NotImplementedError """ +PYPROJECTTOML = """ +[tool.coverage.report] +# Regexes for lines to exclude from consideration +exclude_lines = [ + 'raise NotImplementedError', +] +""" EXCLUDED_TEST = """ @@ -1388,6 +1395,14 @@ def test_coveragerc(testdir): result.stdout.fnmatch_lines([f'test_coveragerc* {EXCLUDED_RESULT}']) +def test_pyproject_toml(testdir): + testdir.makefile('.toml', pyproject=PYPROJECTTOML) + script = testdir.makepyfile(EXCLUDED_TEST) + result = testdir.runpytest('-v', f'--cov={script.dirpath()}', '--cov-report=term-missing', script) + assert result.ret == 0 + result.stdout.fnmatch_lines([f'test_pyproject_toml* {EXCLUDED_RESULT}']) + + @pytest.mark.skipif('sys.platform == "win32" and platform.python_implementation() == "PyPy"') def test_coveragerc_dist(testdir): testdir.makefile('', coveragerc=COVERAGERC)