mutmut icon indicating copy to clipboard operation
mutmut copied to clipboard

mutmut_config.py not skipping the specified ignore

Open BrijeshKrishnan opened this issue 5 years ago • 1 comments

Folder structure

C:\Projects\PythonRepo\mutmut_test>tree /F Folder PATH listing for volume OSDisk Volume serial number is B8EC-CC04

C:.
│   mutmut_config.py
│
├───src
│       sample.py
│       __init__.py
│
└───test
        test_sample.py
        __init__.py```


### Execution result

`C:\Projects\PythonRepo\mutmut_test>mutmut run

- Mutation testing starting -

These are the steps:
1. A full test suite run will be made to make sure we
   can run the tests successfully and we know how long
   it takes (to detect infinite loops for example)
2. Mutants will be generated and checked

Results are stored in .mutmut-cache.
Print found mutants with `mutmut results`.

Legend for output:
🎉 Killed mutants.   The goal is for everything to end up in this bucket.
⏰ Timeout.          Test suite took 10 times as long as the baseline so were killed.
🤔 Suspicious.       Tests took a long time, but not long enough to be fatal.
🙁 Survived.         This means your tests needs to be expanded.

mutmut cache is out of date, clearing it...
1. Running tests without mutations
⠇ Running... Done

2. Checking mutants
⠙ 1/1  🎉 0  ⏰ 0  🤔 0  🙁 1

C:\Projects\PythonRepo\mutmut_test>mutmut show 1
--- src\sample.py
+++ src\sample.py
@@ -4,4 +4,4 @@
     """ TODO """
     def func(self):
         """ TODO """
-        print("this is a sample")
+        print("XXthis is a sampleXX")`




`C:\Projects\PythonRepo\mutmut_test>mutmut --version
mutmut version 2.1.0`



### Code
sample.py



`import os

class dummy():
    """ TODO """
    def func(self):
        """ TODO """
        print("this is a sample")`



test_sample.py



`import os
import sys
import unittest
from sample import dummy

class TestSample(unittest.TestCase):

    def test_fail(self):
        dummyobj = dummy()
        dummyobj.func()
        pass

    
if __name__ == '__main__':
    unittest.main()`

mutmut_config.py


def pre_mutation(context):
    if context.current_source_line.strip().startswith('print('):
        context.skip = True

PLease let me know what could be happening wrong here that i get mutants at print too ? !

BrijeshKrishnan avatar Aug 21 '20 07:08 BrijeshKrishnan

Looks good to me. Could you try deleting the mutmut cache and try again?

boxed avatar Aug 21 '20 11:08 boxed