@@ -48,7 +48,6 @@ def test_bar():
48
48
49
49
"""
50
50
51
-
52
51
COVERAGERC_SOURCE = """\
53
52
[run]
54
53
source = .
@@ -153,8 +152,13 @@ def test_foo(cov):
153
152
154
153
xdist_params = pytest .mark .parametrize (
155
154
'opts' ,
156
- ['' , pytest .param ('-n 1' , marks = pytest .mark .skipif ('sys.platform == "win32" and platform.python_implementation() == "PyPy"' ))],
157
- ids = ['nodist' , 'xdist' ],
155
+ [
156
+ '' ,
157
+ pytest .param ('-n 1' , marks = pytest .mark .skipif ('sys.platform == "win32" and platform.python_implementation() == "PyPy"' )),
158
+ pytest .param ('-n 2' , marks = pytest .mark .skipif ('sys.platform == "win32" and platform.python_implementation() == "PyPy"' )),
159
+ pytest .param ('-n 3' , marks = pytest .mark .skipif ('sys.platform == "win32" and platform.python_implementation() == "PyPy"' )),
160
+ ],
161
+ ids = ['nodist' , '1xdist' , '2xdist' , '3xdist' ],
158
162
)
159
163
160
164
@@ -1631,6 +1635,67 @@ def test_append_coverage(pytester, testdir, opts, prop):
1631
1635
)
1632
1636
1633
1637
1638
+ @xdist_params
1639
+ def test_coverage_plugin (pytester , testdir , opts , prop ):
1640
+ script = testdir .makepyfile (test_1 = prop .code )
1641
+ testdir .makepyfile (
1642
+ coverageplugin = """
1643
+ import coverage
1644
+
1645
+ class ExamplePlugin(coverage.CoveragePlugin):
1646
+ pass
1647
+
1648
+ def coverage_init(reg, options):
1649
+ reg.add_file_tracer(ExamplePlugin())
1650
+ """
1651
+ )
1652
+ testdir .makepyprojecttoml (f"""
1653
+ [tool.coverage.run]
1654
+ plugins = ["coverageplugin"]
1655
+ concurrency = ["thread", "multiprocessing"]
1656
+ { prop .conf }
1657
+ """ )
1658
+ result = testdir .runpytest ('-v' , f'--cov={ script .dirpath ()} ' , script , * opts .split () + prop .args )
1659
+ result .stdout .fnmatch_lines (
1660
+ [
1661
+ f'test_1* { prop .result } *' ,
1662
+ ]
1663
+ )
1664
+
1665
+
1666
+ @xdist_params
1667
+ def test_dynamic_context (pytester , testdir , opts , prop ):
1668
+ script = testdir .makepyfile (test_1 = prop .code )
1669
+ testdir .makepyprojecttoml (f"""
1670
+ [tool.coverage.run]
1671
+ dynamic_context = "test_function"
1672
+ parallel = true
1673
+ { prop .conf }
1674
+ """ )
1675
+ result = testdir .runpytest ('-v' , f'--cov={ script .dirpath ()} ' , script , * opts .split () + prop .args )
1676
+ result .stdout .fnmatch_lines (
1677
+ [
1678
+ f'test_1* { prop .result } *' ,
1679
+ ]
1680
+ )
1681
+
1682
+
1683
+ @xdist_params
1684
+ def test_simple (pytester , testdir , opts , prop ):
1685
+ script = testdir .makepyfile (test_1 = prop .code )
1686
+ testdir .makepyprojecttoml (f"""
1687
+ [tool.coverage.run]
1688
+ parallel = true
1689
+ { prop .conf }
1690
+ """ )
1691
+ result = testdir .runpytest ('-v' , f'--cov={ script .dirpath ()} ' , script , * opts .split () + prop .args )
1692
+ result .stdout .fnmatch_lines (
1693
+ [
1694
+ f'test_1* { prop .result } *' ,
1695
+ ]
1696
+ )
1697
+
1698
+
1634
1699
@xdist_params
1635
1700
def test_do_not_append_coverage (pytester , testdir , opts , prop ):
1636
1701
script = testdir .makepyfile (test_1 = prop .code )
0 commit comments