Skip to content

Commit f1259d6

Browse files
committed
tweak block display
1 parent e19a7e3 commit f1259d6

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

tests/wrong_coverage.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import re
22
import subprocess
33
import sys
4-
from pathlib import Path
54
from tempfile import NamedTemporaryFile
65

76
from pydantic import BaseModel, Field
@@ -26,7 +25,6 @@ def main(exclude_comment: str = 'pragma: no cover') -> int:
2625

2726
blocks: list[str] = []
2827
total_lines = 0
29-
cwd = Path.cwd()
3028
for file_name, file_coverage in r.files.items():
3129
# Find lines that are both excluded and executed
3230
common_lines = sorted(set(file_coverage.excluded_lines) & set(file_coverage.executed_lines))
@@ -43,10 +41,10 @@ def add_block(start: int, end: int):
4341
code_analysise = CodeAnalyzer(file_name)
4442

4543
if not code_analysise.all_block_openings(start, end):
46-
b = str(start) if start == end else f'{start}-{end}'
44+
b = str(start) if start == end else f'{start} to {end}'
4745
if not blocks or blocks[-1] != b:
4846
total_lines += end - start + 1
49-
blocks.append(f' [link=file://{cwd / file_name}]{file_name} {b}[/link]')
47+
blocks.append(f' {file_name}:{b}')
5048

5149
first_line, *rest = common_lines
5250
current_start = current_end = first_line
@@ -64,8 +62,7 @@ def add_block(start: int, end: int):
6462
console = Console()
6563
if blocks:
6664
console.print(f"❎ {total_lines} lines marked with '{exclude_comment}' and covered")
67-
for block in blocks:
68-
console.print(block)
65+
console.print('\n'.join(blocks))
6966
return 1
7067
else:
7168
console.print(f"✅ No lines wrongly marked with '{exclude_comment}'")

0 commit comments

Comments
 (0)