-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_plugin.py
More file actions
53 lines (43 loc) · 1.52 KB
/
Copy pathtest_plugin.py
File metadata and controls
53 lines (43 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# stdlib
import os
from io import StringIO
# 3rd party
import coverage
import pytest
from coincidence import min_version, only_version
from coincidence.regressions import check_file_regression
from coverage.python import PythonParser
from domdf_python_tools.paths import PathPlus
from pytest_regressions.file_regression import FileRegressionFixture
# this package
import coverage_pyver_pragma
@pytest.mark.parametrize(
"version",
[
pytest.param("3.6", marks=only_version(3.6, "Output differs on each version.")),
pytest.param("3.7", marks=only_version(3.7, "Output differs on each version.")),
pytest.param("3.8", marks=only_version(3.8, "Output differs on each version.")),
pytest.param("3.9", marks=only_version(3.9, "Output differs on each version.")),
pytest.param("3.10", marks=min_version("3.10", "Output differs on each version.")),
],
)
def test_plugin(
tmp_pathplus: PathPlus,
file_regression: FileRegressionFixture,
version: str,
) -> None:
coverage_pyver_pragma.coverage_init()
assert PythonParser.lines_matching is coverage_pyver_pragma.PythonParser.lines_matching
cov = coverage.Coverage()
cov.start()
# this package
import tests.demo_code
cov.stop()
cov.save()
output = StringIO()
cov.report(morfs=[tests.demo_code.__file__], file=output)
# cov.html_report(morfs=[tests.demo_code.__file__])
cov.erase()
buf = output.getvalue().replace(tests.demo_code.__file__, "demo_code.py")
buf = buf.replace(os.path.sep, os.path.altsep or os.path.sep)
check_file_regression(buf, file_regression)