Closed qthequartermasterman closed 1 month ago
Yea I guess we should load the resulting file with the ast standard library and if it's invalid just mark it as killed. This should be super fast and just a clean win.
I just released mutmut 3, which is a big rewrite.
The fix I suggested here is implemented in that new code.
I have an odd false-positive surviving mutant (when using the standard pytest runner) involving positional-only and keyword-only arguments.
Consider this function, with two positional-only arguments:
mutmut
tried one mutation which is syntactically invalid (but somehow was still marked as survived???)Ideally,
mutmut
wouldn't generate this mutation because it's a SyntaxError.However, it is only a syntax error if the
*
and**kwargs
are adjacent (i.e. no explicitly named parameters). Consider this:This mutation is syntactically valid, and thus should be tried. Consequently, simply avoiding replacing
/
with*
in function signatures is not sufficient.If there is not an obvious way to only generate the syntactically correct mutants, is there a way to guarantee that mutants with syntax errors are not marked as survived?