Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mutmut/file_mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def function_trampoline_arrangement(function: cst.FunctionDef, mutants: Iterable
nodes.append(mutated_method) # type: ignore

# trampoline that forwards the calls
trampoline = list(cst.parse_module(build_trampoline(orig_name=name, mutants=mutant_names, class_name=class_name)).body)
trampoline = list(cst.parse_module(build_trampoline(orig_name=name, mutants=mutant_names, class_name=class_name, asynchronous=function.asynchronous)).body)
trampoline[0] = trampoline[0].with_changes(leading_lines=[cst.EmptyLine()])
nodes.extend(trampoline)

Expand Down
6 changes: 3 additions & 3 deletions src/mutmut/trampoline_templates.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CLASS_NAME_SEPARATOR = 'ǁ'

def build_trampoline(*, orig_name, mutants, class_name):
def build_trampoline(*, orig_name, mutants, class_name, asynchronous):
mangled_name = mangle_function_name(name=orig_name, class_name=class_name)

mutants_dict = f'{mangled_name}__mutmut_mutants : ClassVar[MutantDict] = {{\n' + ', \n '.join(f'{repr(m)}: {m}' for m in mutants) + '\n}'
Expand All @@ -17,8 +17,8 @@ def build_trampoline(*, orig_name, mutants, class_name):
return f"""
{mutants_dict}

def {orig_name}({'self, ' if class_name is not None else ''}*args, **kwargs):
result = {trampoline_name}({access_prefix}{mangled_name}__mutmut_orig{access_suffix}, {access_prefix}{mangled_name}__mutmut_mutants{access_suffix}, args, kwargs{self_arg})
{'async ' if asynchronous is not None else ''}def {orig_name}({'self, ' if class_name is not None else ''}*args, **kwargs):
result = {'await ' if asynchronous is not None else ''} {trampoline_name}({access_prefix}{mangled_name}__mutmut_orig{access_suffix}, {access_prefix}{mangled_name}__mutmut_mutants{access_suffix}, args, kwargs{self_arg})
return result

{orig_name}.__signature__ = _mutmut_signature({mangled_name}__mutmut_orig)
Expand Down
Loading