Applied mutation causes syntax error
See original GitHub issueHi,
mutmut version: 1.1.0
I’m using Python 3.7 so in my code base I’m using this syntax:
def except_to_bool(_func=None, *, exc=Exception, to=False):
When I apply mutmut it generates this mutant:
def except_to_bool(_func=None, /, exc=Exception, to=False):
which should not be generated as it produces syntax error.
If mutant should be generated here I imagine it should look like this:
def except_to_bool(_func=None, exc=Exception, to=False):
(simply remove star that enforces keyword arguments)
I even have test for this code (which is checking whether it is not possible to pass positional arguments to this function), but mutant still survives it. I think this is because mutant causes syntax error.
Either fix mutant generation with star, that enforces keyword arguments, or skip generating mutant at all in such case, please 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (7 by maintainers)
Top GitHub Comments
True, imports that are broken are for static analysis tools to handle. I’ll fix it.
Maybe we should skip mutating any
import
lines.Is there a way to detect lines defining
import
andfrom foo import bar
statements within aparso.python.tree
. If so we could add a rule to skip mutating these lines. I see no real value in messing up imports for mutation testing, it seems much too high level error injection to validate any real unit tests.