question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Applied mutation causes syntax error

See original GitHub issue

Hi,

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:closed
  • Created 5 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
boxedcommented, Mar 1, 2019

True, imports that are broken are for static analysis tools to handle. I’ll fix it.

0reactions
nklapstecommented, Feb 26, 2019

Maybe we should skip mutating any import lines.

Is there a way to detect lines defining import and from foo import bar statements within a parso.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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQLError: Syntax Error: Unexpected <EOF> when a file ...
GraphQLError: Syntax Error: Unexpected <EOF> when a file only contains commented out query/mutation #4426.
Read more >
Mutations in Apollo Client - Apollo GraphQL Docs
When a mutation's response is insufficient to update all modified fields in your cache (such as certain list fields), you can define an...
Read more >
no mutation was applied. error when using ScalarDB
The following code is giving com.scalar.db.exception.storage.NoMutationException: no mutation was applied. What causes this error and how can I ...
Read more >
Fraction of Error-Generating Mutations Located by Mutation ...
Campbell et al. created Python syntax errors from valid code mined from GitHub by applying mutations on tokens, characters, and lines [3] ....
Read more >
A methodology for extracting a corpus of syntax errors and fixes
syntax error datasets via mutation [3, 7]. Mutation does not ... from GitHub by applying mutations on tokens, characters, and lines [3].
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found