Skip to content

Commit d9a5ba8

Browse files
committed
fix src-layout problems and add syntax heighlight
1 parent 1465724 commit d9a5ba8

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

mutmut/__main__.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ def create_mutants_for_file(filename, output_path):
266266
exit(1)
267267

268268
source_file_mutation_data = SourceFileMutationData(path=filename)
269-
module_name = str(filename)[:-len(filename.suffix)].replace(os.sep, '.')
269+
270+
module_name = strip_prefix(str(filename),prefix="src/")[:-len(filename.suffix)].replace(os.sep, '.')
270271
source_file_mutation_data.exit_code_by_key = {
271272
'.'.join([module_name, x]).replace('.__init__.', '.'): None
272273
for x in mutant_names
@@ -1067,7 +1068,7 @@ def collect_source_file_mutation_data(*, mutant_names):
10671068
source_file_mutation_data_by_path[str(path)] = m
10681069

10691070
mutants = [
1070-
(m, mutant_name, result)
1071+
(m, mutant_name.replace("src.",""), result)
10711072
for path, m in source_file_mutation_data_by_path.items()
10721073
for mutant_name, result in m.exit_code_by_key.items()
10731074
]
@@ -1446,7 +1447,9 @@ def browse():
14461447
from textual.containers import Container
14471448
from textual.widgets import Footer
14481449
from textual.widgets import DataTable
1449-
from textual.widgets import TextArea
1450+
from textual.widgets import Static
1451+
from textual.widget import Widget
1452+
from rich.syntax import Syntax
14501453

14511454
class ResultBrowser(App):
14521455
loading_id = None
@@ -1473,7 +1476,8 @@ def compose(self):
14731476
with Container(classes='container'):
14741477
yield DataTable(id='files')
14751478
yield DataTable(id='mutants')
1476-
yield TextArea(id='diff_view')
1479+
with Widget(id="diff_view_widget"):
1480+
yield Static(id='diff_view')
14771481
yield Footer()
14781482

14791483
def on_mount(self):
@@ -1532,19 +1536,19 @@ def on_data_table_row_highlighted(self, event):
15321536
assert event.data_table.id == 'mutants'
15331537
diff_view = self.query_one('#diff_view')
15341538
if event.row_key.value is None:
1535-
diff_view.text = ''
1539+
diff_view.update('')
15361540
else:
1537-
diff_view.text = '<loading...>'
1541+
diff_view.update('<loading...>')
15381542
self.loading_id = event.row_key.value
15391543

15401544
def load_thread():
15411545
read_config()
15421546
try:
15431547
d = get_diff_for_mutant(event.row_key.value)
15441548
if event.row_key.value == self.loading_id:
1545-
diff_view.text = d
1549+
diff_view.update(Syntax(d,"diff"))
15461550
except Exception as e:
1547-
diff_view.text = f'<{type(e)} {e}>'
1551+
diff_view.update(f'<{type(e)} {e}>')
15481552

15491553
t = Thread(target=load_thread)
15501554
t.start()

mutmut/result_browser_layout.tcss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ DataTable:focus .datatable--cursor {
2424
color: black;
2525
background: orange;
2626
}
27+
28+
#diff_view_widget{
29+
height: 50%;
30+
border: solid;
31+
overflow-y: scroll;
32+
}
33+
34+
#diff_view{
35+
}

0 commit comments

Comments
 (0)