Skip to content

Commit 33a252d

Browse files
committed
fix: some fixes
1 parent 3a3b5fe commit 33a252d

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

mutmut/__main__.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ def guess_paths_to_mutate():
132132

133133

134134
def record_trampoline_hit(name):
135+
if not hasattr(mutmut,"config"):
136+
return
135137
if mutmut.config.max_stack_depth != -1:
136138
f = inspect.currentframe()
137139
c = mutmut.config.max_stack_depth
@@ -181,8 +183,9 @@ class BadTestExecutionCommandsException(Exception):
181183
from inspect import signature as _mutmut_signature
182184
183185
def _mutmut_trampoline(orig, mutants, *args, **kwargs):
186+
__tracebackhide__ = True
184187
import os
185-
mutant_under_test = os.environ['MUTANT_UNDER_TEST']
188+
mutant_under_test = os.environ.get('MUTANT_UNDER_TEST',"")
186189
if mutant_under_test == 'fail':
187190
from mutmut.__main__ import MutmutProgrammaticFailException
188191
raise MutmutProgrammaticFailException('Failed programmatically')
@@ -324,6 +327,7 @@ def build_trampoline(*, orig_name, mutants, class_name, is_generator):
324327
{mutants_dict}
325328
326329
def {orig_name}({'self, ' if class_name is not None else ''}*args, **kwargs):
330+
__tracebackhide__ = True
327331
result = {yield_statement} {trampoline_name}({access_prefix}{mangled_name}__mutmut_orig{access_suffix}, {access_prefix}{mangled_name}__mutmut_mutants{access_suffix}, *args, **kwargs)
328332
return result
329333
@@ -683,6 +687,8 @@ def new_tests(self):
683687
class PytestRunner(TestRunner):
684688
def execute_pytest(self, params, **kwargs):
685689
import pytest
690+
params+=["--rootdir=.","--inline-snapshot=disable"]
691+
print(">","pytest",*params,kwargs)
686692
exit_code = int(pytest.main(params, **kwargs))
687693
if exit_code == 4:
688694
raise BadTestExecutionCommandsException(params)
@@ -706,7 +712,7 @@ def pytest_runtest_makereport(self, item, call):
706712

707713
def run_tests(self, *, mutant_name, tests):
708714
with change_cwd('mutants'):
709-
return int(self.execute_pytest(['-x', '-q', '--import-mode=append'] + list(tests)))
715+
return int(self.execute_pytest(['-x', '--import-mode=append'] + list(tests)))
710716

711717
def run_forced_fail(self):
712718
with change_cwd('mutants'):
@@ -980,12 +986,10 @@ def run_stats_collection(runner, tests=None):
980986

981987
os.environ['MUTANT_UNDER_TEST'] = 'stats'
982988
os.environ['PY_IGNORE_IMPORTMISMATCH'] = '1'
983-
with CatchOutput(show_spinner=True, spinner_title='running stats') as output_catcher:
984-
collect_stats_exit_code = runner.run_stats(tests=tests)
985-
if collect_stats_exit_code != 0:
986-
output_catcher.dump_output()
987-
print(f'failed to collect stats. runner returned {collect_stats_exit_code}')
988-
exit(1)
989+
collect_stats_exit_code = runner.run_stats(tests=tests)
990+
if collect_stats_exit_code != 0:
991+
print(f'failed to collect stats. runner returned {collect_stats_exit_code}')
992+
exit(1)
989993

990994
print(' done')
991995

@@ -1160,6 +1164,12 @@ def run(mutant_names, *, max_children):
11601164
os.environ['MUTANT_UNDER_TEST'] = ''
11611165
with CatchOutput(show_spinner=True, spinner_title='running clean tests') as output_catcher:
11621166
tests = tests_for_mutant_names(mutant_names)
1167+
#print(f"{mutants=}")
1168+
print(f"{mutant_names=}")
1169+
print(f"{tests=}")
1170+
if not tests:
1171+
tests=["tests"]
1172+
11631173

11641174
clean_test_exit_code = runner.run_tests(mutant_name=None, tests=tests)
11651175
if clean_test_exit_code != 0:

0 commit comments

Comments
 (0)