Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pytest-dev/pytest-cov
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9463242
Choose a base ref
...
head repository: pytest-dev/pytest-cov
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b9c99e7
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Sep 17, 2024

  1. Add example test with coverage plugin. Ref #642.

    ionelmc committed Sep 17, 2024
    Copy the full SHA
    b9c99e7 View commit details
Showing with 28 additions and 0 deletions.
  1. +28 −0 tests/test_pytest_cov.py
28 changes: 28 additions & 0 deletions tests/test_pytest_cov.py
Original file line number Diff line number Diff line change
@@ -1631,6 +1631,34 @@ def test_append_coverage(pytester, testdir, opts, prop):
)


@xdist_params
def test_coverage_plugin(pytester, testdir, opts, prop):
script = testdir.makepyfile(test_1=prop.code)
testdir.makepyfile(
coverageplugin="""
import coverage
class ExamplePlugin(coverage.CoveragePlugin):
pass
def coverage_init(reg, options):
reg.add_file_tracer(ExamplePlugin())
"""
)
testdir.makepyprojecttoml(f"""
[tool.coverage.run]
plugins = ["coverageplugin"]
concurrency = ["thread", "multiprocessing"]
{prop.conf}
""")
result = testdir.runpytest('-v', f'--cov={script.dirpath()}', script, *opts.split() + prop.args)
result.stdout.fnmatch_lines(
[
f'test_1* {prop.result}*',
]
)


@xdist_params
def test_do_not_append_coverage(pytester, testdir, opts, prop):
script = testdir.makepyfile(test_1=prop.code)