Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List mutants with mutation_type? #113

Open
AGeekInside opened this issue Apr 19, 2019 · 4 comments
Open

List mutants with mutation_type? #113

AGeekInside opened this issue Apr 19, 2019 · 4 comments
Labels
workflow Enhancements specifically for improving the workflow

Comments

@AGeekInside
Copy link

Hi,

Is there anyone way to list the mutations by the mutation_type? I looked init and noticed that it looks like Mutants can be made of up multiple mutations. I am trying to figure out the best way to get a listing of mutants with the types of mutations in a given Mutant.

It looks like the cache code that refers to the Mutant class doesn't have any field showing the mutations involved in a given mutant, so I wasn't sure how to reconstruct the mutations involved in creating a specific mutant.

The context is that we'd like to be able to prioritize what mutants we examine first, as we start fleshing our tests to address issues found with mutmut.

Marc

@boxed
Copy link
Owner

boxed commented Apr 19, 2019

A mutant In mutmut is a single mutation point and a single possible mutant. One could imagine having multiple mutants for one mutation point (e.g. changing literal 0 to 1 and -1), but I haven't implemented that and no one has reported a case where the lack of this feature would be a problem. It's already slow enough as is so there must be a strong reason to introduce many more mutants to try!

Do you have some idea of what types of mutants you think are more valuable to kill? Because I would love to hear your logic, I haven't come up with such a scenario myself. In my experience the most scary sounding mutant that changes assignment from "a = b" to "a = None" mostly just means there is some dead code in practice. So it's hard to know how to prioritize!

@AGeekInside
Copy link
Author

It's probably more of examples that are not as interesting. I ran mutmut on some code we are looking to test better/more, and some of the mutants were permutations of string constants in logging messages. That's a less interesting than mutations that change the boundary conditions of if statements and such.

Given the large number of surviving mutants in our codebase, I was trying to get my arms around how to prioritize what mutants to look at/work on first. I'm not 100% sure that the mutation types would be the right way to build that prioritized list, but it seemed like mutations of operators, and/or, and numbers might be higher priority than string (for instance).

@boxed boxed added the workflow Enhancements specifically for improving the workflow label Apr 21, 2019
@mrijken
Copy link

mrijken commented Oct 21, 2022

If I understand it well, mutmut has per statement one mutant. And one mutant has 1 change in the statement. That means that a complex statement is mutated only once however multiple or possible. ie the next statement:

value2 = value + (possible_non_value or 1)

will only mutate the or in a and, but will not mutate the + or the 1.

Is that the current behaviour indeed?

@boxed
Copy link
Owner

boxed commented Oct 21, 2022

No, that's not correct. It will mutate that line in 4 ways I believe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workflow Enhancements specifically for improving the workflow
Projects
None yet
Development

No branches or pull requests

3 participants