Skip to content

Commit ce9304a

Browse files
committed
Fix tests
1 parent eeafad2 commit ce9304a

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

tests/unit/test_coverage.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ def test_get_coverage_info(mocker, coverage_json, coverage_obj):
2828
"coverage_comment.subprocess.run", return_value=json.dumps(coverage_json)
2929
)
3030

31-
result = coverage.get_coverage_info(merge=True, coverage_path=".")
31+
result = coverage.get_coverage_info(merge=True, coverage_path=pathlib.Path("."))
3232

3333
assert run.call_args_list == [
34-
mocker.call("coverage", "combine", path="."),
35-
mocker.call("coverage", "json", "-o", "-", path="."),
34+
mocker.call("coverage", "combine", path=pathlib.Path(".")),
35+
mocker.call("coverage", "json", "-o", "-", path=pathlib.Path(".")),
3636
]
3737

3838
assert result == coverage_obj
@@ -43,9 +43,12 @@ def test_get_coverage_info__no_merge(mocker, coverage_json):
4343
"coverage_comment.subprocess.run", return_value=json.dumps(coverage_json)
4444
)
4545

46-
coverage.get_coverage_info(merge=False, coverage_path=".")
46+
coverage.get_coverage_info(merge=False, coverage_path=pathlib.Path("."))
4747

48-
assert mocker.call("coverage", "combine", path=".") not in run.call_args_list
48+
assert (
49+
mocker.call("coverage", "combine", path=pathlib.Path("."))
50+
not in run.call_args_list
51+
)
4952

5053

5154
def test_get_coverage_info__error_base(mocker, get_logs):
@@ -54,7 +57,7 @@ def test_get_coverage_info__error_base(mocker, get_logs):
5457
)
5558

5659
with pytest.raises(subprocess.SubProcessError):
57-
coverage.get_coverage_info(merge=False, coverage_path=".")
60+
coverage.get_coverage_info(merge=False, coverage_path=pathlib.Path("."))
5861

5962
assert not get_logs("ERROR")
6063

@@ -66,7 +69,7 @@ def test_get_coverage_info__error_no_source(mocker, get_logs):
6669
)
6770

6871
with pytest.raises(subprocess.SubProcessError):
69-
coverage.get_coverage_info(merge=False, coverage_path=".")
72+
coverage.get_coverage_info(merge=False, coverage_path=pathlib.Path("."))
7073

7174
assert get_logs("ERROR", "Cannot read")
7275

@@ -77,24 +80,33 @@ def test_generate_coverage_html_files(mocker):
7780
)
7881

7982
coverage.generate_coverage_html_files(
80-
destination=pathlib.Path("/tmp/foo"), coverage_path="."
83+
destination=pathlib.Path("/tmp/foo"), coverage_path=pathlib.Path(".")
8184
)
8285

8386
assert run.call_args_list == [
8487
mocker.call(
85-
"coverage", "html", "--skip-empty", "--directory", "/tmp/foo", path="."
88+
"coverage",
89+
"html",
90+
"--skip-empty",
91+
"--directory",
92+
"/tmp/foo",
93+
path=pathlib.Path("."),
8694
),
8795
]
8896

8997

9098
def test_generate_coverage_markdown(mocker):
9199
run = mocker.patch("coverage_comment.subprocess.run", return_value="foo")
92100

93-
result = coverage.generate_coverage_markdown(coverage_path=".")
101+
result = coverage.generate_coverage_markdown(coverage_path=pathlib.Path("."))
94102

95103
assert run.call_args_list == [
96104
mocker.call(
97-
"coverage", "report", "--format=markdown", "--show-missing", path="."
105+
"coverage",
106+
"report",
107+
"--format=markdown",
108+
"--show-missing",
109+
path=pathlib.Path("."),
98110
),
99111
]
100112

tests/unit/test_template.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import datetime
22
import decimal
3+
import pathlib
34

45
import pytest
56

@@ -86,8 +87,8 @@ def test_template_full():
8687
missing_branches=0,
8788
),
8889
files={
89-
"codebase/code.py": coverage.FileCoverage(
90-
path="codebase/code.py",
90+
pathlib.Path("codebase/code.py"): coverage.FileCoverage(
91+
path=pathlib.Path("codebase/code.py"),
9192
executed_lines=[1, 2, 5, 6, 9],
9293
missing_lines=[],
9394
excluded_lines=[],
@@ -103,8 +104,8 @@ def test_template_full():
103104
missing_branches=0,
104105
),
105106
),
106-
"codebase/other.py": coverage.FileCoverage(
107-
path="codebase/other.py",
107+
pathlib.Path("codebase/other.py"): coverage.FileCoverage(
108+
path=pathlib.Path("codebase/other.py"),
108109
executed_lines=[1, 2, 3],
109110
missing_lines=[],
110111
excluded_lines=[],
@@ -129,13 +130,13 @@ def test_template_full():
129130
total_percent_covered=decimal.Decimal("1"),
130131
num_changed_lines=39,
131132
files={
132-
"codebase/code.py": coverage.FileDiffCoverage(
133-
path="codebase/code.py",
133+
pathlib.Path("codebase/code.py"): coverage.FileDiffCoverage(
134+
path=pathlib.Path("codebase/code.py"),
134135
percent_covered=decimal.Decimal("0.5"),
135136
violation_lines=[5],
136137
),
137-
"codebase/other.py": coverage.FileDiffCoverage(
138-
path="codebase/other.py",
138+
pathlib.Path("codebase/other.py"): coverage.FileDiffCoverage(
139+
path=pathlib.Path("codebase/other.py"),
139140
percent_covered=decimal.Decimal("1"),
140141
violation_lines=[],
141142
),

0 commit comments

Comments
 (0)