mutmut 2.4.4__tar.gz → 3.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mutmut-2.4.4 → mutmut-3.2.3}/AUTHORS.rst +2 -9
- {mutmut-2.4.4 → mutmut-3.2.3}/HISTORY.rst +49 -47
- {mutmut-2.4.4 → mutmut-3.2.3}/MANIFEST.in +2 -1
- mutmut-3.2.3/PKG-INFO +215 -0
- mutmut-3.2.3/README.rst +191 -0
- mutmut-3.2.3/mutmut/.DS_Store +0 -0
- mutmut-3.2.3/mutmut/__init__.py +317 -0
- mutmut-3.2.3/mutmut/__main__.py +1695 -0
- mutmut-3.2.3/mutmut/__pycache__/__init__.cpython-311.pyc +0 -0
- mutmut-3.2.3/mutmut/__pycache__/__init__.cpython-312.pyc +0 -0
- mutmut-3.2.3/mutmut/__pycache__/__main__.cpython-311.pyc +0 -0
- mutmut-3.2.3/mutmut/__pycache__/__main__.cpython-312.pyc +0 -0
- mutmut-3.2.3/mutmut/result_browser_layout.tcss +34 -0
- mutmut-3.2.3/mutmut.egg-info/PKG-INFO +215 -0
- mutmut-3.2.3/mutmut.egg-info/SOURCES.txt +29 -0
- mutmut-3.2.3/mutmut.egg-info/entry_points.txt +2 -0
- mutmut-3.2.3/mutmut.egg-info/requires.txt +8 -0
- {mutmut-2.4.4 → mutmut-3.2.3}/mutmut.egg-info/top_level.txt +1 -0
- mutmut-3.2.3/requirements.txt +7 -0
- {mutmut-2.4.4 → mutmut-3.2.3}/setup.cfg +1 -13
- {mutmut-2.4.4 → mutmut-3.2.3}/setup.py +8 -21
- mutmut-3.2.3/tests/__init__.py +0 -0
- mutmut-3.2.3/tests/test_mutation.py +409 -0
- mutmut-3.2.3/tests/test_mutmut3.py +83 -0
- mutmut-2.4.4/PKG-INFO +0 -393
- mutmut-2.4.4/README.rst +0 -372
- mutmut-2.4.4/mutmut/__init__.py +0 -1354
- mutmut-2.4.4/mutmut/__main__.py +0 -490
- mutmut-2.4.4/mutmut/cache.py +0 -522
- mutmut-2.4.4/mutmut.egg-info/PKG-INFO +0 -393
- mutmut-2.4.4/mutmut.egg-info/SOURCES.txt +0 -19
- mutmut-2.4.4/mutmut.egg-info/entry_points.txt +0 -3
- mutmut-2.4.4/mutmut.egg-info/requires.txt +0 -16
- mutmut-2.4.4/requirements.txt +0 -6
- mutmut-2.4.4/test_requirements.txt +0 -6
- {mutmut-2.4.4 → mutmut-3.2.3}/LICENSE +0 -0
- {mutmut-2.4.4 → mutmut-3.2.3}/mutmut.egg-info/dependency_links.txt +0 -0
- {mutmut-2.4.4 → mutmut-3.2.3}/mutmut.egg-info/not-zip-safe +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Credits
|
|
3
3
|
=======
|
|
4
4
|
|
|
5
|
-
* Anders Hovmöller <
|
|
5
|
+
* Anders Hovmöller <boxed@killingar.net>
|
|
6
6
|
* Felipe Pontes <felipemfpontes@gmail.com>
|
|
7
7
|
* William Orr <will@worrbase.com>
|
|
8
8
|
* Trevin Gandhi <trevin.gandhi@petuum.com>
|
|
@@ -20,11 +20,4 @@ Credits
|
|
|
20
20
|
* Emil Stenström <emil@emilstenstrom.se>
|
|
21
21
|
* Roxane Bellott <roxane.bellot@gmail.com>
|
|
22
22
|
* Tomáš Chvátal <tchvatal@suse.com>
|
|
23
|
-
*
|
|
24
|
-
* Andreas Finkler <andi.finkler@gmail.com>
|
|
25
|
-
* sed-i
|
|
26
|
-
* Peter Hill <peter.hill@york.ac.uk>
|
|
27
|
-
* Samuel Razzell <srazzell@apple.com>
|
|
28
|
-
* Daniel Versoza Alves <daniel.alves@voxy.com>
|
|
29
|
-
* Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
|
|
30
|
-
* Jan Królikowski <yanekk86@gmail.com>
|
|
23
|
+
* Frank Hoffmann <15r10nk-git@polarbit.de>
|
|
@@ -1,102 +1,104 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
---------
|
|
3
3
|
|
|
4
|
-
2.
|
|
4
|
+
3.2.3
|
|
5
5
|
~~~~~
|
|
6
6
|
|
|
7
|
-
*
|
|
7
|
+
* Crash with error message on invalid imports for `src` module
|
|
8
8
|
|
|
9
|
-
*
|
|
9
|
+
* Autodetect simpler project configurations with `test_*.py` in the dir directly
|
|
10
10
|
|
|
11
|
-
*
|
|
11
|
+
* Handle filenames (as opposed to dirnames) in paths_to_mutate
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
~~~~~
|
|
13
|
+
* Also copy `setup.cfg` and `pyproject.toml` by default
|
|
15
14
|
|
|
16
|
-
*
|
|
15
|
+
* Handle single line `paths_to_mutate`
|
|
17
16
|
|
|
18
|
-
* Added `--CI` flag
|
|
19
17
|
|
|
18
|
+
3.2.2
|
|
19
|
+
~~~~~
|
|
20
20
|
|
|
21
|
+
* Fixed crash when running `mutmut results`
|
|
21
22
|
|
|
22
|
-
2.
|
|
23
|
+
3.2.1
|
|
23
24
|
~~~~~
|
|
24
25
|
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
* Fixed junitxml line number, daemon warning, and missing argument in unit test (thanks Samuel Razzell)
|
|
26
|
+
* Read `paths_to_mutate` from config file
|
|
28
27
|
|
|
28
|
+
* Mutate `break` to `return` to avoid timeouts
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
~~~~~
|
|
30
|
+
* Added debug mode. Enable with `debug=True` in `setup.cfg` under `[mutmut]`
|
|
32
31
|
|
|
33
|
-
*
|
|
32
|
+
* Fixed new test detection. The old code incorrectly detected new tests when there were none, creating a much slower interaction loop for fixing mutants.
|
|
34
33
|
|
|
35
|
-
*
|
|
34
|
+
* And many more fixes
|
|
36
35
|
|
|
37
|
-
2.
|
|
36
|
+
3.2.0
|
|
38
37
|
~~~~~
|
|
39
38
|
|
|
40
|
-
*
|
|
39
|
+
* Timeouts for mutants implemented.
|
|
40
|
+
|
|
41
|
+
* Browser: syntax highlighting for diff view
|
|
41
42
|
|
|
42
|
-
*
|
|
43
|
+
* More fixes for generators.
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
* Fix for `src`-style layout of projects.
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
* Fixed bug where mutmut would recollect all tests on every run, slowing down startup.
|
|
47
48
|
|
|
48
|
-
which now becomes
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
3.1.0
|
|
51
|
+
~~~~~
|
|
51
52
|
|
|
52
|
-
*
|
|
53
|
+
* Correctly handle mutation for generator functions (`yield`).
|
|
53
54
|
|
|
54
|
-
*
|
|
55
|
+
* Fixed so that `from __future__` lines are always first.
|
|
55
56
|
|
|
56
|
-
*
|
|
57
|
+
* If no stats are collected exit directly, as that is a breaking error for mutation testing.
|
|
57
58
|
|
|
59
|
+
* Changed name mangling to make mutants less likely to trigger name-based python magic, like in pytest where functions named `test_*` have special meaning.
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
|
|
62
|
+
3.0.5
|
|
60
63
|
~~~~~
|
|
61
64
|
|
|
62
|
-
*
|
|
65
|
+
* Another attempt to get the pypi package to work
|
|
63
66
|
|
|
64
|
-
* Fixed error where ``mutmut_config.init()`` was not called when running without explicitly having set ``PYTHONPATH``
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
work the same as before, with the exception of ``mutmut --version``, which now has to be ``mutmut version``.
|
|
68
|
+
3.0.4
|
|
69
|
+
~~~~~
|
|
69
70
|
|
|
70
|
-
*
|
|
71
|
-
Coverage contexts are now accessible in ``config.coverage_data`` to help with the selection.
|
|
71
|
+
* Another attempt to get the pypi package to work
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
3.0.3
|
|
74
74
|
~~~~~
|
|
75
75
|
|
|
76
|
-
*
|
|
76
|
+
* Fixed missing requirement in install package
|
|
77
77
|
|
|
78
|
-
*
|
|
78
|
+
* Fixed missing file from the install package
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
3.0.2
|
|
81
|
+
~~~~~
|
|
81
82
|
|
|
82
|
-
* Fixed
|
|
83
|
+
* Fixed bad entrypoint definition
|
|
83
84
|
|
|
84
|
-
*
|
|
85
|
+
* Ignore files that can't be parsed by `parso`
|
|
85
86
|
|
|
86
|
-
* Misc fixes
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
3.0.1
|
|
89
89
|
~~~~~
|
|
90
90
|
|
|
91
|
-
*
|
|
91
|
+
* Missed a file in distribution, so `browse` command was broken.
|
|
92
|
+
|
|
93
|
+
3.0.0
|
|
94
|
+
~~~~~
|
|
92
95
|
|
|
93
|
-
*
|
|
96
|
+
* Execution model switched to mutation schemata, which enabled parallell execution.
|
|
94
97
|
|
|
95
|
-
*
|
|
98
|
+
* New terminal UI
|
|
96
99
|
|
|
97
|
-
*
|
|
100
|
+
* Pytest only, which enabled better integration, cutting execution time significantly.
|
|
98
101
|
|
|
99
|
-
* Advanced whitelisting: More advanced AST level callback
|
|
100
102
|
|
|
101
103
|
2.0.0
|
|
102
104
|
~~~~~
|
mutmut-3.2.3/PKG-INFO
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: mutmut
|
|
3
|
+
Version: 3.2.3
|
|
4
|
+
Summary: mutation testing for Python 3
|
|
5
|
+
Home-page: https://github.com/boxed/mutmut
|
|
6
|
+
Author: Anders Hovmöller
|
|
7
|
+
Author-email: boxed@killingar.net
|
|
8
|
+
License: BSD
|
|
9
|
+
Keywords: mutmut mutant mutation test testing
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
License-File: AUTHORS.rst
|
|
18
|
+
Requires-Dist: parso
|
|
19
|
+
Requires-Dist: click
|
|
20
|
+
Requires-Dist: junit-xml==1.8
|
|
21
|
+
Requires-Dist: setproctitle
|
|
22
|
+
Requires-Dist: textual
|
|
23
|
+
Requires-Dist: toml>=0.10.2; python_version < "3.11"
|
|
24
|
+
|
|
25
|
+
mutmut - python mutation tester
|
|
26
|
+
===============================
|
|
27
|
+
|
|
28
|
+
.. image:: https://github.com/boxed/mutmut/actions/workflows/tests.yml/badge.svg
|
|
29
|
+
:target: https://github.com/boxed/mutmut/actions/workflows/tests.yml
|
|
30
|
+
|
|
31
|
+
.. image:: https://readthedocs.org/projects/mutmut/badge/?version=latest
|
|
32
|
+
:target: https://mutmut.readthedocs.io/en/latest/?badge=latest
|
|
33
|
+
:alt: Documentation Status
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
Mutmut is a mutation testing system for Python, with a strong focus on ease
|
|
37
|
+
of use. If you don't know what mutation testing is try starting with
|
|
38
|
+
`this article <https://kodare.net/2016/12/01/mutmut-a-python-mutation-testing-system.html>`_.
|
|
39
|
+
|
|
40
|
+
Some highlight features:
|
|
41
|
+
|
|
42
|
+
- Found mutants can be applied on disk with a simple command making it very
|
|
43
|
+
easy to work with the results
|
|
44
|
+
- Remembers work that has been done, so you can work incrementally
|
|
45
|
+
- Knows which tests to execute, speeding up mutation testing
|
|
46
|
+
- Interactive terminal based UI
|
|
47
|
+
- Parallel and fast execution
|
|
48
|
+
|
|
49
|
+
.. image:: browse_screenshot.png
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
If you want to mutate code outside of functions, you can try using mutmut 2,
|
|
53
|
+
which has a different execution model than mutmut 3+.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
Requirements
|
|
57
|
+
------------
|
|
58
|
+
|
|
59
|
+
Mutmut must be run on a system with `fork` support. This means that if you want
|
|
60
|
+
to run on windows, you must run inside WSL.
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
Install and run
|
|
65
|
+
---------------
|
|
66
|
+
|
|
67
|
+
You can get started with a simple:
|
|
68
|
+
|
|
69
|
+
.. code-block:: console
|
|
70
|
+
|
|
71
|
+
pip install mutmut
|
|
72
|
+
mutmut run
|
|
73
|
+
|
|
74
|
+
This will by run pytest on tests in the "tests" or "test" folder and
|
|
75
|
+
it will try to figure out where the code to mutate is.
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
You can stop the mutation run at any time and mutmut will restart where you
|
|
80
|
+
left off. It will continue where it left off, and re-test functions that were
|
|
81
|
+
modified since last run.
|
|
82
|
+
|
|
83
|
+
To work with the results, use `mutmut browse` where you can see the mutants,
|
|
84
|
+
retest them when you've updated your tests.
|
|
85
|
+
|
|
86
|
+
You can also write a mutant to disk from the `browse` interface, or via
|
|
87
|
+
`mutmut apply <mutant>`. You should **REALLY** have the file you mutate under
|
|
88
|
+
source code control and committed before you apply a mutant!
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
Configuration
|
|
92
|
+
-------------
|
|
93
|
+
|
|
94
|
+
In `setup.cfg` in the root of your project you can configure mutmut if you need to:
|
|
95
|
+
|
|
96
|
+
.. code-block:: ini
|
|
97
|
+
|
|
98
|
+
[mutmut]
|
|
99
|
+
paths_to_mutate=src/
|
|
100
|
+
tests_dir=tests/
|
|
101
|
+
|
|
102
|
+
See below for more options for configuring mutmut.
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
Wildcards for testing mutants
|
|
106
|
+
-----------------------------
|
|
107
|
+
|
|
108
|
+
Unix filename pattern matching style on mutants is supported. Example:
|
|
109
|
+
|
|
110
|
+
.. code-block:: console
|
|
111
|
+
|
|
112
|
+
mutmut run "my_module*"
|
|
113
|
+
mutmut run "my_module.my_function*"
|
|
114
|
+
|
|
115
|
+
In the `browse` TUI you can press `f` to retest a function, and `m` to retest
|
|
116
|
+
an entire module.
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
"also copy" files
|
|
120
|
+
-----------------
|
|
121
|
+
|
|
122
|
+
To run the full test suite some files are often needed above the tests and the
|
|
123
|
+
source. You can configure to copy extra files that you need by adding
|
|
124
|
+
directories and files to `also_copy` in your `setup.cfg`:
|
|
125
|
+
|
|
126
|
+
.. code-block:: ini
|
|
127
|
+
|
|
128
|
+
also_copy=
|
|
129
|
+
iommi/snapshots/
|
|
130
|
+
conftest.py
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
Limit stack depth
|
|
134
|
+
-----------------
|
|
135
|
+
|
|
136
|
+
In big code bases some functions are called incidentally by huge swaths of the
|
|
137
|
+
codebase, but you really don't want tests that hit those executions to count
|
|
138
|
+
for mutation testing purposes. Incidentally tested functions lead to slow
|
|
139
|
+
mutation testing as hundreds of tests can be checked for things that should
|
|
140
|
+
have clean and fast unit tests, and it leads to bad test suites as any
|
|
141
|
+
introduced bug in those base functions will lead to many tests that fail which
|
|
142
|
+
are hard to understand how they relate to the function with the change.
|
|
143
|
+
|
|
144
|
+
You can configure mutmut to only count a test as being relevant for a function
|
|
145
|
+
if the stack depth from the test to the function is below some limit. In your
|
|
146
|
+
`setup.cfg` add:
|
|
147
|
+
|
|
148
|
+
.. code-block:: ini
|
|
149
|
+
|
|
150
|
+
max_stack_depth=8
|
|
151
|
+
|
|
152
|
+
A lower value will increase mutation speed and lead to more localized tests,
|
|
153
|
+
but will also lead to more surviving mutants that would otherwise have been
|
|
154
|
+
caught.
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
Exclude files from mutation
|
|
158
|
+
---------------------------
|
|
159
|
+
|
|
160
|
+
You can exclude files from mutation in `setup.cfg`:
|
|
161
|
+
|
|
162
|
+
.. code-block::
|
|
163
|
+
|
|
164
|
+
do_not_mutate=
|
|
165
|
+
*__tests.py
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
Whitelisting
|
|
169
|
+
------------
|
|
170
|
+
|
|
171
|
+
You can mark lines like this:
|
|
172
|
+
|
|
173
|
+
.. code-block:: python
|
|
174
|
+
|
|
175
|
+
some_code_here() # pragma: no mutate
|
|
176
|
+
|
|
177
|
+
to stop mutation on those lines. Some cases we've found where you need to
|
|
178
|
+
whitelist lines are:
|
|
179
|
+
|
|
180
|
+
- The version string on your library. You really shouldn't have a test for this :P
|
|
181
|
+
- Optimizing break instead of continue. The code runs fine when mutating break
|
|
182
|
+
to continue, but it's slower.
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
Example mutations
|
|
186
|
+
-----------------
|
|
187
|
+
|
|
188
|
+
- Integer literals are changed by adding 1. So 0 becomes 1, 5 becomes 6, etc.
|
|
189
|
+
- `<` is changed to `<=`
|
|
190
|
+
- break is changed to continue and vice versa
|
|
191
|
+
|
|
192
|
+
In general the idea is that the mutations should be as subtle as possible.
|
|
193
|
+
See `__init__.py` for the full list.
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
Workflow
|
|
197
|
+
--------
|
|
198
|
+
|
|
199
|
+
This section describes how to work with mutmut to enhance your test suite.
|
|
200
|
+
|
|
201
|
+
1. Run mutmut with `mutmut run`. A full run is preferred but if you're just
|
|
202
|
+
getting started you can exit in the middle and start working with what you
|
|
203
|
+
have found so far.
|
|
204
|
+
2. Show the mutants with `mutmut browse`
|
|
205
|
+
3. Find a mutant you want to work on and write a test to try to kill it.
|
|
206
|
+
4. Press `r` to rerun the mutant and see if you successfully managed to kill it.
|
|
207
|
+
|
|
208
|
+
Mutmut keeps the data of what it has done and the mutants in the `mutants/`
|
|
209
|
+
directory.If you want to make sure you run a full mutmut run you can delete
|
|
210
|
+
this directory to start from scratch.
|
|
211
|
+
|
|
212
|
+
Contributing to Mutmut
|
|
213
|
+
----------------------
|
|
214
|
+
|
|
215
|
+
If you wish to contribute to Mutmut, please see our `contributing guide <CONTRIBUTING.rst>`_.
|
mutmut-3.2.3/README.rst
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
mutmut - python mutation tester
|
|
2
|
+
===============================
|
|
3
|
+
|
|
4
|
+
.. image:: https://github.com/boxed/mutmut/actions/workflows/tests.yml/badge.svg
|
|
5
|
+
:target: https://github.com/boxed/mutmut/actions/workflows/tests.yml
|
|
6
|
+
|
|
7
|
+
.. image:: https://readthedocs.org/projects/mutmut/badge/?version=latest
|
|
8
|
+
:target: https://mutmut.readthedocs.io/en/latest/?badge=latest
|
|
9
|
+
:alt: Documentation Status
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Mutmut is a mutation testing system for Python, with a strong focus on ease
|
|
13
|
+
of use. If you don't know what mutation testing is try starting with
|
|
14
|
+
`this article <https://kodare.net/2016/12/01/mutmut-a-python-mutation-testing-system.html>`_.
|
|
15
|
+
|
|
16
|
+
Some highlight features:
|
|
17
|
+
|
|
18
|
+
- Found mutants can be applied on disk with a simple command making it very
|
|
19
|
+
easy to work with the results
|
|
20
|
+
- Remembers work that has been done, so you can work incrementally
|
|
21
|
+
- Knows which tests to execute, speeding up mutation testing
|
|
22
|
+
- Interactive terminal based UI
|
|
23
|
+
- Parallel and fast execution
|
|
24
|
+
|
|
25
|
+
.. image:: browse_screenshot.png
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
If you want to mutate code outside of functions, you can try using mutmut 2,
|
|
29
|
+
which has a different execution model than mutmut 3+.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Requirements
|
|
33
|
+
------------
|
|
34
|
+
|
|
35
|
+
Mutmut must be run on a system with `fork` support. This means that if you want
|
|
36
|
+
to run on windows, you must run inside WSL.
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
Install and run
|
|
41
|
+
---------------
|
|
42
|
+
|
|
43
|
+
You can get started with a simple:
|
|
44
|
+
|
|
45
|
+
.. code-block:: console
|
|
46
|
+
|
|
47
|
+
pip install mutmut
|
|
48
|
+
mutmut run
|
|
49
|
+
|
|
50
|
+
This will by run pytest on tests in the "tests" or "test" folder and
|
|
51
|
+
it will try to figure out where the code to mutate is.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
You can stop the mutation run at any time and mutmut will restart where you
|
|
56
|
+
left off. It will continue where it left off, and re-test functions that were
|
|
57
|
+
modified since last run.
|
|
58
|
+
|
|
59
|
+
To work with the results, use `mutmut browse` where you can see the mutants,
|
|
60
|
+
retest them when you've updated your tests.
|
|
61
|
+
|
|
62
|
+
You can also write a mutant to disk from the `browse` interface, or via
|
|
63
|
+
`mutmut apply <mutant>`. You should **REALLY** have the file you mutate under
|
|
64
|
+
source code control and committed before you apply a mutant!
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
Configuration
|
|
68
|
+
-------------
|
|
69
|
+
|
|
70
|
+
In `setup.cfg` in the root of your project you can configure mutmut if you need to:
|
|
71
|
+
|
|
72
|
+
.. code-block:: ini
|
|
73
|
+
|
|
74
|
+
[mutmut]
|
|
75
|
+
paths_to_mutate=src/
|
|
76
|
+
tests_dir=tests/
|
|
77
|
+
|
|
78
|
+
See below for more options for configuring mutmut.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
Wildcards for testing mutants
|
|
82
|
+
-----------------------------
|
|
83
|
+
|
|
84
|
+
Unix filename pattern matching style on mutants is supported. Example:
|
|
85
|
+
|
|
86
|
+
.. code-block:: console
|
|
87
|
+
|
|
88
|
+
mutmut run "my_module*"
|
|
89
|
+
mutmut run "my_module.my_function*"
|
|
90
|
+
|
|
91
|
+
In the `browse` TUI you can press `f` to retest a function, and `m` to retest
|
|
92
|
+
an entire module.
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
"also copy" files
|
|
96
|
+
-----------------
|
|
97
|
+
|
|
98
|
+
To run the full test suite some files are often needed above the tests and the
|
|
99
|
+
source. You can configure to copy extra files that you need by adding
|
|
100
|
+
directories and files to `also_copy` in your `setup.cfg`:
|
|
101
|
+
|
|
102
|
+
.. code-block:: ini
|
|
103
|
+
|
|
104
|
+
also_copy=
|
|
105
|
+
iommi/snapshots/
|
|
106
|
+
conftest.py
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
Limit stack depth
|
|
110
|
+
-----------------
|
|
111
|
+
|
|
112
|
+
In big code bases some functions are called incidentally by huge swaths of the
|
|
113
|
+
codebase, but you really don't want tests that hit those executions to count
|
|
114
|
+
for mutation testing purposes. Incidentally tested functions lead to slow
|
|
115
|
+
mutation testing as hundreds of tests can be checked for things that should
|
|
116
|
+
have clean and fast unit tests, and it leads to bad test suites as any
|
|
117
|
+
introduced bug in those base functions will lead to many tests that fail which
|
|
118
|
+
are hard to understand how they relate to the function with the change.
|
|
119
|
+
|
|
120
|
+
You can configure mutmut to only count a test as being relevant for a function
|
|
121
|
+
if the stack depth from the test to the function is below some limit. In your
|
|
122
|
+
`setup.cfg` add:
|
|
123
|
+
|
|
124
|
+
.. code-block:: ini
|
|
125
|
+
|
|
126
|
+
max_stack_depth=8
|
|
127
|
+
|
|
128
|
+
A lower value will increase mutation speed and lead to more localized tests,
|
|
129
|
+
but will also lead to more surviving mutants that would otherwise have been
|
|
130
|
+
caught.
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
Exclude files from mutation
|
|
134
|
+
---------------------------
|
|
135
|
+
|
|
136
|
+
You can exclude files from mutation in `setup.cfg`:
|
|
137
|
+
|
|
138
|
+
.. code-block::
|
|
139
|
+
|
|
140
|
+
do_not_mutate=
|
|
141
|
+
*__tests.py
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
Whitelisting
|
|
145
|
+
------------
|
|
146
|
+
|
|
147
|
+
You can mark lines like this:
|
|
148
|
+
|
|
149
|
+
.. code-block:: python
|
|
150
|
+
|
|
151
|
+
some_code_here() # pragma: no mutate
|
|
152
|
+
|
|
153
|
+
to stop mutation on those lines. Some cases we've found where you need to
|
|
154
|
+
whitelist lines are:
|
|
155
|
+
|
|
156
|
+
- The version string on your library. You really shouldn't have a test for this :P
|
|
157
|
+
- Optimizing break instead of continue. The code runs fine when mutating break
|
|
158
|
+
to continue, but it's slower.
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
Example mutations
|
|
162
|
+
-----------------
|
|
163
|
+
|
|
164
|
+
- Integer literals are changed by adding 1. So 0 becomes 1, 5 becomes 6, etc.
|
|
165
|
+
- `<` is changed to `<=`
|
|
166
|
+
- break is changed to continue and vice versa
|
|
167
|
+
|
|
168
|
+
In general the idea is that the mutations should be as subtle as possible.
|
|
169
|
+
See `__init__.py` for the full list.
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
Workflow
|
|
173
|
+
--------
|
|
174
|
+
|
|
175
|
+
This section describes how to work with mutmut to enhance your test suite.
|
|
176
|
+
|
|
177
|
+
1. Run mutmut with `mutmut run`. A full run is preferred but if you're just
|
|
178
|
+
getting started you can exit in the middle and start working with what you
|
|
179
|
+
have found so far.
|
|
180
|
+
2. Show the mutants with `mutmut browse`
|
|
181
|
+
3. Find a mutant you want to work on and write a test to try to kill it.
|
|
182
|
+
4. Press `r` to rerun the mutant and see if you successfully managed to kill it.
|
|
183
|
+
|
|
184
|
+
Mutmut keeps the data of what it has done and the mutants in the `mutants/`
|
|
185
|
+
directory.If you want to make sure you run a full mutmut run you can delete
|
|
186
|
+
this directory to start from scratch.
|
|
187
|
+
|
|
188
|
+
Contributing to Mutmut
|
|
189
|
+
----------------------
|
|
190
|
+
|
|
191
|
+
If you wish to contribute to Mutmut, please see our `contributing guide <CONTRIBUTING.rst>`_.
|
|
Binary file
|