Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
57 lines (40 sloc) 1.48 KB

Mutant not killed due to module import issue

Example of how importing modules under different names allows mutations to survive. In this case the problem is related to how Cosmic-Ray loads the mutated modules. It has already been fixed in PR #158.


$ pip install
$ celery -A cosmic_ray.tasks.worker worker

$ cosmic-ray run --baseline=10 example.json sandwich/ham/ -- tests
$ cosmic-ray report example.json
job ID 1:Outcome.SURVIVED:sandwich.ham.ham
command: cosmic-ray worker sandwich.ham.ham number_replacer 0 unittest -- tests
--- mutation diff ---
--- a/sandwich/ham/
+++ b/sandwich/ham/
@@ -3,6 +3,6 @@

 class Ham(object):

-    def __init__(self, pieces=10):
+    def __init__(self, pieces=11):
         self.pieces = pieces

total jobs: 1
complete: 1 (100.00%)
survival rate: 100.00%


In this example properly kills the mutant once the above issue is fixed.

Source code

.. literalinclude:: sandwich/ham/
    :caption: sandwich/ham/
    :language: python

.. literalinclude:: sandwich/
    :caption: sandwich/
    :language: python

.. literalinclude:: tests/
    :caption: tests/
    :language: python
You can’t perform that action at this time.