Skip to content

Commit

Permalink
Fix bug in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ewjoachim committed Jan 6, 2024
1 parent e0c33e9 commit e886962
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 7 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,13 @@ def _(code: str, has_branches: bool = True) -> coverage_module.Coverage:
)
line_number = 0
# (we start at 0 because the first line will be empty for readabilty)
for line in code.splitlines()[1:]:
for line in code.splitlines():
line = line.strip()
if not line:
continue
if line.startswith("# file: "):
current_file = pathlib.Path(line.split("# file: ")[1])
line_number = 0
continue
assert current_file, (line, current_file, code)
line_number += 1
Expand Down Expand Up @@ -383,8 +386,10 @@ def _(code: str) -> tuple[coverage_module.Coverage, coverage_module.DiffCoverage
current_file = None
# (we start at 0 because the first line will be empty for readabilty)
line_number = 0
for line in code.splitlines()[1:]:
for line in code.splitlines():
line = line.strip()
if not line:
continue
if line.startswith("# file: "):
new_code += line + "\n"
current_file = pathlib.Path(line.split("# file: ")[1])
Expand Down
7 changes: 3 additions & 4 deletions tests/unit/test_diff_grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def test_group_annotations_more_files(
)

assert list(result) == [
groups.Group(file=pathlib.Path("codebase/code.py"), line_start=6, line_end=8),
groups.Group(
file=pathlib.Path("codebase/other.py"), line_start=17, line_end=17
),
groups.Group(file=pathlib.Path("codebase/code.py"), line_start=5, line_end=8),
groups.Group(file=pathlib.Path("codebase/other.py"), line_start=1, line_end=1),
groups.Group(file=pathlib.Path("codebase/other.py"), line_start=3, line_end=5),
]

0 comments on commit e886962

Please sign in to comment.