No project description provided
Project description
Mutmut
======
Mutmut is a mutation testing library/tool. It aims to be usable as a program directly, but also to have an easy to use API.
Install
-------
.. code-block::
pip install mutmut
Usage
-----
.. code-block::
mutmut path/to/directory/you/want/to/mutate
This will by default run py.test on tests in the "tests" folder. Run
.. code-block::
mutmut --help
for the available flags to use other runners, etc.
The output of the mutation tests (if you have surviving mutants) looks like:
.. code-block::
FAILED: mutmut path/filename.py --mutation 10 --apply
I've made is to you can just copy paste everything after "FAILED:" and run it directly and you'll get the
mutant on disk. You should REALLY have the file you mutate under source code control and committed before you mutate it!
You should start from the bottom of the list, because if you start from the top, the indexes of the mutations change.
You can mark lines like this:
.. code-block:: python
some_code_here() # pragma: no mutate
to stop mutation on those lines. Some cases we've found where you need to whitelist lines are:
- The version string on your library. You really shouldn't have a test for this :P
- Optimizing break instead of continue. The code runs fine when mutating break to continue, but it's slower.
Example mutations
-----------------
- Integer literals are changed by adding 1. So 0 becomes 1, 5 becomes 6, etc.
- < is changed to <=
- break is changed to continue and vice versa
In general the idea is that the mutations should be as subtle as possible.
Future plan
-----------
- Custom importer that will mutate the code on the way in
- Plug in to py.test (and nose, etc?) to make it use the importer
- Optimization: Keep a cache of hashes to know which files have changed since they were tested, so we can skip testing files which are already done
- Optimization: Use testmon to know which tests to rerun for each mutation
- Speed up: Make the runner itself a part of py.test so we can use py.test test parallelization/distribution
Changelog
---------
0.0.11 (2017-08-03)
~~~~~~~~~~~~~~~~~~~
* Fixed bug that made mutmut crash when setup.cfg was missing
0.0.10 (2017-07-16)
~~~~~~~~~~~~~~~~~~~
* Renamed parameter `--testsdir` to `--tests-dir`
* Refactored handling of setup.cfg file. Much cleaner solution and adds `--dict-synonyms` command line parameter
0.0.9 (2017-07-05)
~~~~~~~~~~~~~~~~~~
* Bug with dict param mutations: it mutated all parameters, this could vastly decrease the odds of finding a mutant
* New mutation: remove the body or return 0 instead of None
0.0.8 (2017-06-28)
~~~~~~~~~~~~~~~~~~
* Previous version had broken version on pypi
0.0.7 (2017-06-28)
~~~~~~~~~~~~~~~~~~
* Fixed bug where pragma didn't work for decorator mutations
* Dict literals looking like `dict(a=foo)` now have mutated keys. You can also declare synonyms in setup.cfg.
* Fix "from x import *"
0.0.6 (2017-06-13)
~~~~~~~~~~~~~~~~~~
* New mutation: remove decorators!
* Improved status while running. This should make it easier to handle when you hit mutants that cause infinite loops.
* Fixes failing attempts to mutate parentheses. (Thanks Hristo Georgiev!)
0.0.5 (2017-05-06)
~~~~~~~~~~~~~~~~~~
* Try to fix pypi package
0.0.4 (2017-05-06)
~~~~~~~~~~~~~~~~~~
* Try to fix pypi package
0.0.3 (2017-05-05)
~~~~~~~~~~~~~~~~~~
* Python 3 support (as far as baron supports it anyway)
* Try running without mutations first to make sure we can run the test suite cleanly before starting mutation
* Implemented feature to run mutation on covered lines only, this is useful for mutation testing existing tests when you don't have 100% coverage
* Error message on incorrect invocation
0.0.2 (2016-12-01)
~~~~~~~~~~~~~~~~~~
* Tons of fixes
0.0.1 (2016-12-01)
~~~~~~~~~~~~~~~~~~
* Initial version
======
Mutmut is a mutation testing library/tool. It aims to be usable as a program directly, but also to have an easy to use API.
Install
-------
.. code-block::
pip install mutmut
Usage
-----
.. code-block::
mutmut path/to/directory/you/want/to/mutate
This will by default run py.test on tests in the "tests" folder. Run
.. code-block::
mutmut --help
for the available flags to use other runners, etc.
The output of the mutation tests (if you have surviving mutants) looks like:
.. code-block::
FAILED: mutmut path/filename.py --mutation 10 --apply
I've made is to you can just copy paste everything after "FAILED:" and run it directly and you'll get the
mutant on disk. You should REALLY have the file you mutate under source code control and committed before you mutate it!
You should start from the bottom of the list, because if you start from the top, the indexes of the mutations change.
You can mark lines like this:
.. code-block:: python
some_code_here() # pragma: no mutate
to stop mutation on those lines. Some cases we've found where you need to whitelist lines are:
- The version string on your library. You really shouldn't have a test for this :P
- Optimizing break instead of continue. The code runs fine when mutating break to continue, but it's slower.
Example mutations
-----------------
- Integer literals are changed by adding 1. So 0 becomes 1, 5 becomes 6, etc.
- < is changed to <=
- break is changed to continue and vice versa
In general the idea is that the mutations should be as subtle as possible.
Future plan
-----------
- Custom importer that will mutate the code on the way in
- Plug in to py.test (and nose, etc?) to make it use the importer
- Optimization: Keep a cache of hashes to know which files have changed since they were tested, so we can skip testing files which are already done
- Optimization: Use testmon to know which tests to rerun for each mutation
- Speed up: Make the runner itself a part of py.test so we can use py.test test parallelization/distribution
Changelog
---------
0.0.11 (2017-08-03)
~~~~~~~~~~~~~~~~~~~
* Fixed bug that made mutmut crash when setup.cfg was missing
0.0.10 (2017-07-16)
~~~~~~~~~~~~~~~~~~~
* Renamed parameter `--testsdir` to `--tests-dir`
* Refactored handling of setup.cfg file. Much cleaner solution and adds `--dict-synonyms` command line parameter
0.0.9 (2017-07-05)
~~~~~~~~~~~~~~~~~~
* Bug with dict param mutations: it mutated all parameters, this could vastly decrease the odds of finding a mutant
* New mutation: remove the body or return 0 instead of None
0.0.8 (2017-06-28)
~~~~~~~~~~~~~~~~~~
* Previous version had broken version on pypi
0.0.7 (2017-06-28)
~~~~~~~~~~~~~~~~~~
* Fixed bug where pragma didn't work for decorator mutations
* Dict literals looking like `dict(a=foo)` now have mutated keys. You can also declare synonyms in setup.cfg.
* Fix "from x import *"
0.0.6 (2017-06-13)
~~~~~~~~~~~~~~~~~~
* New mutation: remove decorators!
* Improved status while running. This should make it easier to handle when you hit mutants that cause infinite loops.
* Fixes failing attempts to mutate parentheses. (Thanks Hristo Georgiev!)
0.0.5 (2017-05-06)
~~~~~~~~~~~~~~~~~~
* Try to fix pypi package
0.0.4 (2017-05-06)
~~~~~~~~~~~~~~~~~~
* Try to fix pypi package
0.0.3 (2017-05-05)
~~~~~~~~~~~~~~~~~~
* Python 3 support (as far as baron supports it anyway)
* Try running without mutations first to make sure we can run the test suite cleanly before starting mutation
* Implemented feature to run mutation on covered lines only, this is useful for mutation testing existing tests when you don't have 100% coverage
* Error message on incorrect invocation
0.0.2 (2016-12-01)
~~~~~~~~~~~~~~~~~~
* Tons of fixes
0.0.1 (2016-12-01)
~~~~~~~~~~~~~~~~~~
* Initial version
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mutmut-0.0.11.tar.gz
(11.2 kB
view details)
File details
Details for the file mutmut-0.0.11.tar.gz
.
File metadata
- Download URL: mutmut-0.0.11.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99b607f4ca73b6b362316c0d9ba7f810076fb257cf9191f66ca7f50b5a5cc5f9 |
|
MD5 | c66b05d64b336f6635c82a1f0b519085 |
|
BLAKE2b-256 | ec1707a69703eb50041b921808bc979e419dc8a1ca74fbcf8f990abea0dac6e4 |