1- import pytest
21from inline_snapshot import snapshot
32import libcst as cst
43
@@ -66,7 +65,6 @@ def foo(self, a, b):
6665 """ )
6766
6867
69- @pytest .mark .skip (reason = "WIP type checking implementation" )
7068def test_module_mutation ():
7169 """Regression test, for a complete module with functions, type annotations and a class"""
7270
@@ -101,33 +99,33 @@ def add(self, value):
10199from typing import Callable
102100from typing import ClassVar
103101
104- MutantDict = Annotated[dict[str, Callable], "Mutant"]
102+ MutantDict = Annotated[dict[str, Callable], "Mutant"] # type: ignore
105103
106104
107- def _mutmut_trampoline(orig, mutants, call_args, call_kwargs, self_arg = None):
105+ def _mutmut_trampoline(orig, mutants, call_args, call_kwargs, self_arg = None): # type: ignore
108106 """Forward call to original or mutated function, depending on the environment"""
109- import os
110- mutant_under_test = os.environ['MUTANT_UNDER_TEST']
111- if mutant_under_test == 'fail':
112- from mutmut.__main__ import MutmutProgrammaticFailException
113- raise MutmutProgrammaticFailException('Failed programmatically') \n \
114- elif mutant_under_test == 'stats':
115- from mutmut.__main__ import record_trampoline_hit
116- record_trampoline_hit(orig.__module__ + '.' + orig.__name__)
107+ import os # type: ignore
108+ mutant_under_test = os.environ['MUTANT_UNDER_TEST'] # type: ignore
109+ if mutant_under_test == 'fail': # type: ignore
110+ from mutmut.__main__ import MutmutProgrammaticFailException # type: ignore
111+ raise MutmutProgrammaticFailException('Failed programmatically') # type: ignore
112+ elif mutant_under_test == 'stats': # type: ignore
113+ from mutmut.__main__ import record_trampoline_hit # type: ignore
114+ record_trampoline_hit(orig.__module__ + '.' + orig.__name__) # type: ignore
117115 # (for class methods, orig is bound and thus does not need the explicit self argument)
118- result = orig(*call_args, **call_kwargs)
119- return result
120- prefix = orig.__module__ + '.' + orig.__name__ + '__mutmut_'
121- if not mutant_under_test.startswith(prefix):
122- result = orig(*call_args, **call_kwargs)
123- return result
124- mutant_name = mutant_under_test.rpartition('.')[-1]
125- if self_arg is not None:
116+ result = orig(*call_args, **call_kwargs) # type: ignore
117+ return result # type: ignore
118+ prefix = orig.__module__ + '.' + orig.__name__ + '__mutmut_' # type: ignore
119+ if not mutant_under_test.startswith(prefix): # type: ignore
120+ result = orig(*call_args, **call_kwargs) # type: ignore
121+ return result # type: ignore
122+ mutant_name = mutant_under_test.rpartition('.')[-1] # type: ignore
123+ if self_arg is not None: # type: ignore
126124 # call to a class method where self is not bound
127- result = mutants[mutant_name](self_arg, *call_args, **call_kwargs)
125+ result = mutants[mutant_name](self_arg, *call_args, **call_kwargs) # type: ignore
128126 else:
129- result = mutants[mutant_name](*call_args, **call_kwargs)
130- return result
127+ result = mutants[mutant_name](*call_args, **call_kwargs) # type: ignore
128+ return result # type: ignore
131129
132130def x_foo__mutmut_orig(a: list[int], b):
133131 return a[0] > b
@@ -143,7 +141,7 @@ def foo(a: list[int], b):
143141 kwargs = {}
144142 return _mutmut_trampoline(x_foo__mutmut_orig, x_foo__mutmut_mutants, args, kwargs, None)
145143
146- x_foo__mutmut_mutants : ClassVar[MutantDict] = {
144+ x_foo__mutmut_mutants : ClassVar[MutantDict] = { # type: ignore
147145'x_foo__mutmut_1': x_foo__mutmut_1, \n \
148146 'x_foo__mutmut_2': x_foo__mutmut_2
149147}
@@ -160,7 +158,7 @@ def bar():
160158 kwargs = {}
161159 return _mutmut_trampoline(x_bar__mutmut_orig, x_bar__mutmut_mutants, args, kwargs, None)
162160
163- x_bar__mutmut_mutants : ClassVar[MutantDict] = {
161+ x_bar__mutmut_mutants : ClassVar[MutantDict] = { # type: ignore
164162'x_bar__mutmut_1': x_bar__mutmut_1
165163}
166164x_bar__mutmut_orig.__name__ = 'x_bar'
@@ -175,7 +173,7 @@ def __init__(self, amount):
175173 kwargs = {}
176174 return _mutmut_trampoline(object.__getattribute__(self, 'xǁAdderǁ__init____mutmut_orig'), object.__getattribute__(self, 'xǁAdderǁ__init____mutmut_mutants'), args, kwargs, self)
177175 \n \
178- xǁAdderǁ__init____mutmut_mutants : ClassVar[MutantDict] = {
176+ xǁAdderǁ__init____mutmut_mutants : ClassVar[MutantDict] = { # type: ignore
179177 'xǁAdderǁ__init____mutmut_1': xǁAdderǁ__init____mutmut_1
180178 }
181179 xǁAdderǁ__init____mutmut_orig.__name__ = 'xǁAdderǁ__init__'
@@ -191,7 +189,7 @@ def add(self, value):
191189 kwargs = {}
192190 return _mutmut_trampoline(object.__getattribute__(self, 'xǁAdderǁadd__mutmut_orig'), object.__getattribute__(self, 'xǁAdderǁadd__mutmut_mutants'), args, kwargs, self)
193191 \n \
194- xǁAdderǁadd__mutmut_mutants : ClassVar[MutantDict] = {
192+ xǁAdderǁadd__mutmut_mutants : ClassVar[MutantDict] = { # type: ignore
195193 'xǁAdderǁadd__mutmut_1': xǁAdderǁadd__mutmut_1
196194 }
197195 xǁAdderǁadd__mutmut_orig.__name__ = 'xǁAdderǁadd'
0 commit comments