Fails to skip lines when context.skip set True in pre_mutation
johnesher opened this issue · 3 comments
This is my pre_mutation function in mutmut_config.py
def pre_mutation(context):
line = context.current_source_line.strip()
print('testing', line)
if line.startswith('log'):
print('skipping', line)
context.skip = True
if line.startswith('print'):
print('skipping', line)
context.skip = True
I can see it is being executed from the prints but it does not stop the mutations as shown by the snippet below
Mutant 29
--- <path hidden>/handlers.py
+++ <path hidden>/handlers.py
@@ -12,7 +12,7 @@
# from <hidden>
-logger = logging.getLogger(__name__)
+logger = None
logger.setLevel(logging.DEBUG)
Mutant 30
--- <path hidden>/handlers.py
+++ <path hidden>/handlers.py
@@ -19,7 +19,7 @@
def handle_event(event: events.NormalEvent) -> None:
"""TODO docstring"""
# tick
- print(f"### handling {event}")
+ print(f"XX### handling {event}XX")
logger.info("handling %s", event)
# whatever
There is no setup/config file and I am running mutmut like this
mutmut run --disable-mutation-types=string,number
I would expect the string in the print above not to be mutated.
Version is mutmut version 2.5.0
and running with python 3.10 in a venv on Ubuntu 22.04
The output you showed looks like the mutmut show
output. That just shows that mutmut has enumerated the mutant, not that it has tested that mutant.
Thanks that helps me to understand. I have quite a lot of items skipped at the moment and they make it hard to see the real mutants that need to be addressed in the report. Is there an option to omit skipped mutants from the report?
It also seems to me that the behaviour of --disable-mutation-types
is unclear. Adding it halved the number of mutants, but some strings still survived as in this one below
Survived mutation testing. These mutants show holes in your test suite.
Mutant 126
--- src/example_client.py
+++ src/example_client.py
@@ -30,7 +30,7 @@
def doing_something_that_sends_an_event(self):
# return for test purposes
- return self.send_event("it happened")
+ return self.send_event("XXit happenedXX")
And it's not just that that mutant was checked when you didn't have that conf? The cache will remember mutants...