Skip to content

Conversation

@Otto-AA
Copy link
Collaborator

@Otto-AA Otto-AA commented Apr 6, 2025

While testing I found two errors in the mutation setup:

The same-args bug only occurs when calling methods with the keywords orig or mutants. e.g. if foo(orig=123) was called somewhere. This already fails at the clean test run, so nobody reporting it as an issue seems like no one uses these kwargs. I only noticed when running mutmut on mutmut self.

The self-parameter bug killed all class method mutations, because the mutations did not receive self as an argument and are not bound to any class instance. Unluckily, it worked for the original method, because the original method is passed as a bound method and does not require self to be passed as an argument, so the clean tests run did not notice this error. Fixing this bug will result in a decent amount of new survived mutants for projects that use classes.

The commit messages contain more technical details. For the self-parameter bug, I will submit an E2E snapshot test in the next days that would detect a regression that accidentally introduces it again.

Otto-AA added 2 commits April 6, 2025 09:04
Previously, mutmut would fail on a function call that
contains the kwarg `orig` or `mutants`, e.g. `foo(orig=123)`.

The trampoline setup would try to call
`_mutmut_trampoline(foo_orig, foo_mutants, *args, **kwargs)`
which now has the argument `orig` twice (once as a
positional arg and once as a kwarg) and thus raise
a TypeError.
Previously, mutated class methods were
always killed, because no `self` arg
was passed to their calls and thus
raised a TypeError for invalid number
of arguments.

The class methods in the mutants dict are
stored without reference to any class instance
and therefore not bound to any instance.
We need to pass the `self` arg explicitly
in those cases.

Note that the call to the original method
is a bound method (the method is looked up
via the `self` parameter), thus we do not
pass the `self` arg in this case.
@Otto-AA Otto-AA changed the title Mutation fixes Mutation trampoline fixes Apr 6, 2025
@Otto-AA Otto-AA mentioned this pull request Apr 8, 2025
4 tasks
@boxed boxed merged commit 49720e3 into boxed:main Apr 8, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants