Skip to content

Commit

Permalink
Add example test with coverage plugin. Ref #642.
Browse files Browse the repository at this point in the history
  • Loading branch information
ionelmc committed Sep 17, 2024
1 parent 310feb0 commit b9c99e7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_pytest_cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b9c99e7

Please sign in to comment.