Skip to content

Commit e886962

Browse files
committed
Fix bug in tests
1 parent e0c33e9 commit e886962

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

tests/conftest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,13 @@ def _(code: str, has_branches: bool = True) -> coverage_module.Coverage:
291291
)
292292
line_number = 0
293293
# (we start at 0 because the first line will be empty for readabilty)
294-
for line in code.splitlines()[1:]:
294+
for line in code.splitlines():
295295
line = line.strip()
296+
if not line:
297+
continue
296298
if line.startswith("# file: "):
297299
current_file = pathlib.Path(line.split("# file: ")[1])
300+
line_number = 0
298301
continue
299302
assert current_file, (line, current_file, code)
300303
line_number += 1
@@ -383,8 +386,10 @@ def _(code: str) -> tuple[coverage_module.Coverage, coverage_module.DiffCoverage
383386
current_file = None
384387
# (we start at 0 because the first line will be empty for readabilty)
385388
line_number = 0
386-
for line in code.splitlines()[1:]:
389+
for line in code.splitlines():
387390
line = line.strip()
391+
if not line:
392+
continue
388393
if line.startswith("# file: "):
389394
new_code += line + "\n"
390395
current_file = pathlib.Path(line.split("# file: ")[1])

tests/unit/test_diff_grouper.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ def test_group_annotations_more_files(
2424
)
2525

2626
assert list(result) == [
27-
groups.Group(file=pathlib.Path("codebase/code.py"), line_start=6, line_end=8),
28-
groups.Group(
29-
file=pathlib.Path("codebase/other.py"), line_start=17, line_end=17
30-
),
27+
groups.Group(file=pathlib.Path("codebase/code.py"), line_start=5, line_end=8),
28+
groups.Group(file=pathlib.Path("codebase/other.py"), line_start=1, line_end=1),
29+
groups.Group(file=pathlib.Path("codebase/other.py"), line_start=3, line_end=5),
3130
]

0 commit comments

Comments
 (0)