mutmut 2.5.0__tar.gz → 3.0.0__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-3.0.0/AUTHORS.rst +22 -0
- {mutmut-2.5.0 → mutmut-3.0.0}/HISTORY.rst +4 -111
- mutmut-3.0.0/PKG-INFO +204 -0
- mutmut-3.0.0/README.rst +176 -0
- mutmut-3.0.0/mutmut/__init__.py +308 -0
- mutmut-3.0.0/mutmut/__main__.py +1500 -0
- mutmut-3.0.0/mutmut.egg-info/PKG-INFO +204 -0
- {mutmut-2.5.0 → mutmut-3.0.0}/mutmut.egg-info/SOURCES.txt +3 -5
- {mutmut-2.5.0 → mutmut-3.0.0}/mutmut.egg-info/requires.txt +2 -5
- mutmut-3.0.0/requirements.txt +4 -0
- {mutmut-2.5.0 → mutmut-3.0.0}/setup.cfg +1 -10
- {mutmut-2.5.0 → mutmut-3.0.0}/setup.py +4 -7
- {mutmut-2.5.0 → mutmut-3.0.0}/test_requirements.txt +0 -2
- mutmut-3.0.0/tests/test_mutation.py +339 -0
- mutmut-3.0.0/tests/test_mutmut3.py +80 -0
- mutmut-2.5.0/AUTHORS.rst +0 -39
- mutmut-2.5.0/PKG-INFO +0 -422
- mutmut-2.5.0/README.rst +0 -390
- mutmut-2.5.0/mutmut/__init__.py +0 -1336
- mutmut-2.5.0/mutmut/__main__.py +0 -542
- mutmut-2.5.0/mutmut/cache.py +0 -528
- mutmut-2.5.0/mutmut.egg-info/PKG-INFO +0 -422
- mutmut-2.5.0/requirements.txt +0 -6
- mutmut-2.5.0/tests/test_cache.py +0 -40
- mutmut-2.5.0/tests/test_init.py +0 -183
- mutmut-2.5.0/tests/test_main.py +0 -719
- mutmut-2.5.0/tests/test_mutation.py +0 -393
- mutmut-2.5.0/tests/test_mutmut_config_hooks.py +0 -61
- {mutmut-2.5.0 → mutmut-3.0.0}/LICENSE +0 -0
- {mutmut-2.5.0 → mutmut-3.0.0}/MANIFEST.in +0 -0
- {mutmut-2.5.0 → mutmut-3.0.0}/mutmut.egg-info/dependency_links.txt +0 -0
- {mutmut-2.5.0 → mutmut-3.0.0}/mutmut.egg-info/entry_points.txt +0 -0
- {mutmut-2.5.0 → mutmut-3.0.0}/mutmut.egg-info/not-zip-safe +0 -0
- {mutmut-2.5.0 → mutmut-3.0.0}/mutmut.egg-info/top_level.txt +0 -0
mutmut-3.0.0/AUTHORS.rst
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
=======
|
|
2
|
+
Credits
|
|
3
|
+
=======
|
|
4
|
+
|
|
5
|
+
* Anders Hovmöller <boxed@killingar.net>
|
|
6
|
+
* Felipe Pontes <felipemfpontes@gmail.com>
|
|
7
|
+
* William Orr <will@worrbase.com>
|
|
8
|
+
* Trevin Gandhi <trevin.gandhi@petuum.com>
|
|
9
|
+
* Daniel Hahler <git@thequod.de>
|
|
10
|
+
* Marcelo Da Cruz Pinto
|
|
11
|
+
* Jakub Stolarski
|
|
12
|
+
* Hristo Georgiev
|
|
13
|
+
* Savo Kovačević <savo.s.kovacevic@gmail.com>
|
|
14
|
+
* Nathan Klapstein <nklapste@ualberta.ca>
|
|
15
|
+
* Brian Skinn <brian.skinn@gmail.com>
|
|
16
|
+
* Jim Jazwiecki <jim.jazwiecki@gmail.com>
|
|
17
|
+
* neroks <gneroks@gmail.com>
|
|
18
|
+
* John Vandenberg <jayvdb@gmail.com>
|
|
19
|
+
* Luca Simonetto <luca.simonetto.94@gmail.com>
|
|
20
|
+
* Emil Stenström <emil@emilstenstrom.se>
|
|
21
|
+
* Roxane Bellott <roxane.bellot@gmail.com>
|
|
22
|
+
* Tomáš Chvátal <tchvatal@suse.com>
|
|
@@ -1,122 +1,15 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
---------
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
3.0.0
|
|
5
5
|
~~~~~
|
|
6
6
|
|
|
7
|
-
*
|
|
7
|
+
* Execution model switched to mutation schemata, which enabled parallell execution.
|
|
8
8
|
|
|
9
|
-
*
|
|
9
|
+
* New terminal UI
|
|
10
10
|
|
|
11
|
-
*
|
|
11
|
+
* Pytest only, which enabled better integration, cutting execution time significantly.
|
|
12
12
|
|
|
13
|
-
2.4.5
|
|
14
|
-
~~~~~
|
|
15
|
-
|
|
16
|
-
* Add skipped column in html index report
|
|
17
|
-
|
|
18
|
-
* Untested/skipped in show all does not show skipped
|
|
19
|
-
|
|
20
|
-
* mutmut should pick up the config before running the original tests. That allows to specify test suits you want to run
|
|
21
|
-
|
|
22
|
-
* improved some high-level help text & documentation
|
|
23
|
-
|
|
24
|
-
2.4.4
|
|
25
|
-
~~~~~
|
|
26
|
-
|
|
27
|
-
* Fix issue with `TypeError` for empty file diffs
|
|
28
|
-
|
|
29
|
-
* Introduce mutation of f-strings
|
|
30
|
-
|
|
31
|
-
* Allow newer versions of junit-xml
|
|
32
|
-
|
|
33
|
-
2.4.3
|
|
34
|
-
~~~~~
|
|
35
|
-
|
|
36
|
-
* Fix for a big where worker cycling would just hang mutmut (thanks Jan Królikowski!)
|
|
37
|
-
|
|
38
|
-
* Added `--CI` flag
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
2.4.2
|
|
43
|
-
~~~~~
|
|
44
|
-
|
|
45
|
-
* Fix bug with init db on wrong function (thanks Samuel Razzell)
|
|
46
|
-
|
|
47
|
-
* Fixed junitxml line number, daemon warning, and missing argument in unit test (thanks Samuel Razzell)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
2.4.1
|
|
51
|
-
~~~~~
|
|
52
|
-
|
|
53
|
-
* Support paths with path separators
|
|
54
|
-
|
|
55
|
-
* Disable spinner in no-progress mode
|
|
56
|
-
|
|
57
|
-
2.4.0
|
|
58
|
-
~~~~~
|
|
59
|
-
|
|
60
|
-
* Add pyproject support (thanks sed-i)
|
|
61
|
-
|
|
62
|
-
* Change very small or very large numbers (floats) by a relative amount (thanks Peter Hill)
|
|
63
|
-
|
|
64
|
-
This avoids (some) problems with unkillable mutants, for example:
|
|
65
|
-
|
|
66
|
-
1e16 -> 1e+16
|
|
67
|
-
|
|
68
|
-
which now becomes
|
|
69
|
-
|
|
70
|
-
1e16 -> 2e+16
|
|
71
|
-
|
|
72
|
-
* Fix inconsistent output of `mutmut show` after using `--enable-mutation-types` (thanks Andreas Finkler)
|
|
73
|
-
|
|
74
|
-
* Improve test selection through ``pre_mutation(context)`` (thanks Andreas Finkler)
|
|
75
|
-
|
|
76
|
-
* Remove `--cache-only` option and second argument to `mutmut show` (thanks Andreas Finkler)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
2.3.0
|
|
80
|
-
~~~~~
|
|
81
|
-
|
|
82
|
-
* Add `--disable-mutation-types` and `--enable-mutation-types` to control what types of mutations are performed
|
|
83
|
-
|
|
84
|
-
* Fixed error where ``mutmut_config.init()`` was not called when running without explicitly having set ``PYTHONPATH``
|
|
85
|
-
|
|
86
|
-
* Use ``Click``'s subcommand feature to refactor the command line interface. For the end user, this can now run ``mutmut [COMMAND] -h``
|
|
87
|
-
to check which parameters are relevant to this specific subcommand. The change is backwards compatible, and all existing commands
|
|
88
|
-
work the same as before, with the exception of ``mutmut --version``, which now has to be ``mutmut version``.
|
|
89
|
-
|
|
90
|
-
* You can now set the ``context.config.test_command`` in the ``mutmut_config.pre_mutation(context)`` hook to select the relevant subset of tests.
|
|
91
|
-
Coverage contexts are now accessible in ``config.coverage_data`` to help with the selection.
|
|
92
|
-
|
|
93
|
-
2.2.0
|
|
94
|
-
~~~~~
|
|
95
|
-
|
|
96
|
-
* Add ability to update progress output only after test passes (`--no-progress`)
|
|
97
|
-
|
|
98
|
-
* Added option `--simple-output` to disable usage of emojis in output
|
|
99
|
-
|
|
100
|
-
* Fixed the total mutants and killed column in html report (#184)
|
|
101
|
-
|
|
102
|
-
* Fixed paths_to_exclude config parsing
|
|
103
|
-
|
|
104
|
-
* Stricter error code check for test runners. The previous check sometimes counted no tests as a killed mutant
|
|
105
|
-
|
|
106
|
-
* Misc fixes
|
|
107
|
-
|
|
108
|
-
2.1.0
|
|
109
|
-
~~~~~
|
|
110
|
-
|
|
111
|
-
* Support unittest, so you don't need pytest anymore
|
|
112
|
-
|
|
113
|
-
* Fixed a bug where Ctrl+C wouldn't exit mutmut
|
|
114
|
-
|
|
115
|
-
* Support for Coverage 5
|
|
116
|
-
|
|
117
|
-
* Skip mutating test files if they are in the same source tree as the main code
|
|
118
|
-
|
|
119
|
-
* Advanced whitelisting: More advanced AST level callback
|
|
120
13
|
|
|
121
14
|
2.0.0
|
|
122
15
|
~~~~~
|
mutmut-3.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: mutmut
|
|
3
|
+
Version: 3.0.0
|
|
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
|
+
Provides-Extra: pytest
|
|
23
|
+
Requires-Dist: pytest; extra == "pytest"
|
|
24
|
+
Provides-Extra: coverage
|
|
25
|
+
Requires-Dist: coverage; extra == "coverage"
|
|
26
|
+
Provides-Extra: patch
|
|
27
|
+
Requires-Dist: whatthepatch==0.0.6; extra == "patch"
|
|
28
|
+
|
|
29
|
+
mutmut - python mutation tester
|
|
30
|
+
===============================
|
|
31
|
+
|
|
32
|
+
.. image:: https://github.com/boxed/mutmut/actions/workflows/tests.yml/badge.svg
|
|
33
|
+
:target: https://github.com/boxed/mutmut/actions/workflows/tests.yml
|
|
34
|
+
|
|
35
|
+
.. image:: https://readthedocs.org/projects/mutmut/badge/?version=latest
|
|
36
|
+
:target: https://mutmut.readthedocs.io/en/latest/?badge=latest
|
|
37
|
+
:alt: Documentation Status
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
Mutmut is a mutation testing system for Python, with a strong focus on ease
|
|
41
|
+
of use. If you don't know what mutation testing is try starting with
|
|
42
|
+
`this article <https://kodare.net/2016/12/01/mutmut-a-python-mutation-testing-system.html>`_.
|
|
43
|
+
|
|
44
|
+
Some highlight features:
|
|
45
|
+
|
|
46
|
+
- Found mutants can be applied on disk with a simple command making it very
|
|
47
|
+
easy to work with the results
|
|
48
|
+
- Remembers work that has been done, so you can work incrementally
|
|
49
|
+
- Knows which tests to execute, speeding up mutation testing
|
|
50
|
+
- Interactive terminal based UI
|
|
51
|
+
- Parallel and fast execution
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
If you want to mutate code outside of functions, you can try using mutmut 2,
|
|
55
|
+
which has a different execution model than mutmut 3+.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
Requirements
|
|
59
|
+
------------
|
|
60
|
+
|
|
61
|
+
Mutmut must be run on a system with `fork` support. This means that if you want
|
|
62
|
+
to run on windows, you must run inside WSL.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
Install and run
|
|
67
|
+
---------------
|
|
68
|
+
|
|
69
|
+
You can get started with a simple:
|
|
70
|
+
|
|
71
|
+
.. code-block:: console
|
|
72
|
+
|
|
73
|
+
pip install mutmut
|
|
74
|
+
mutmut run
|
|
75
|
+
|
|
76
|
+
This will by run pytest on tests in the "tests" or "test" folder and
|
|
77
|
+
it will try to figure out where the code to mutate is.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
.. code-block:: ini
|
|
82
|
+
|
|
83
|
+
[mutmut]
|
|
84
|
+
paths_to_mutate=src/
|
|
85
|
+
tests_dir=tests/
|
|
86
|
+
|
|
87
|
+
You can stop the mutation run at any time and mutmut will restart where you
|
|
88
|
+
left off. It will continue where it left off, and re-test functions that were
|
|
89
|
+
modified since last run.
|
|
90
|
+
|
|
91
|
+
To work with the results, use `mutmut browse` where you can see the mutants,
|
|
92
|
+
retest them when you've updated your tests.
|
|
93
|
+
|
|
94
|
+
You can also write a mutant to disk from the `browse` interface, or via
|
|
95
|
+
`mutmut apply <mutant>`. You should **REALLY** have the file you mutate under
|
|
96
|
+
source code control and committed before you apply a mutant!
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
Wildcards for testing mutants
|
|
100
|
+
-----------------------------
|
|
101
|
+
|
|
102
|
+
Unix filename pattern matching style on mutants is supported. Example:
|
|
103
|
+
|
|
104
|
+
.. code-block:: console
|
|
105
|
+
|
|
106
|
+
mutmut run "my_module*"
|
|
107
|
+
mutmut run "my_module.my_function*"
|
|
108
|
+
|
|
109
|
+
In the `browse` TUI you can press `f` to retest a function, and `m` to retest
|
|
110
|
+
an entire module.
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
"also copy" files
|
|
114
|
+
-----------------
|
|
115
|
+
|
|
116
|
+
To run the full test suite some files are often needed above the tests and the
|
|
117
|
+
source. You can configure to copy extra files that you need by adding
|
|
118
|
+
directories and files to `also_copy` in your `setup.cfg`:
|
|
119
|
+
|
|
120
|
+
.. code-block:: ini
|
|
121
|
+
|
|
122
|
+
also_copy=
|
|
123
|
+
iommi/snapshots/
|
|
124
|
+
conftest.py
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
Limit stack depth
|
|
128
|
+
-----------------
|
|
129
|
+
|
|
130
|
+
In big code bases some functions are called incidentally by huge swaths of the
|
|
131
|
+
codebase, but you really don't want tests that hit those executions to count
|
|
132
|
+
for mutation testing purposes. Incidentally tested functions lead to slow
|
|
133
|
+
mutation testing as hundreds of tests can be checked for things that should
|
|
134
|
+
have clean and fast unit tests, and it leads to bad test suites as any
|
|
135
|
+
introduced bug in those base functions will lead to many tests that fail which
|
|
136
|
+
are hard to understand how they relate to the function with the change.
|
|
137
|
+
|
|
138
|
+
You can configure mutmut to only count a test as being relevant for a function
|
|
139
|
+
if the stack depth from the test to the function is below some limit. In your
|
|
140
|
+
`setup.cfg` add:
|
|
141
|
+
|
|
142
|
+
.. code-block:: ini
|
|
143
|
+
|
|
144
|
+
max_stack_depth=8
|
|
145
|
+
|
|
146
|
+
A lower value will increase mutation speed and lead to more localized tests,
|
|
147
|
+
but will also lead to more surviving mutants that would otherwise have been
|
|
148
|
+
caught.
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
Exclude files from mutation
|
|
152
|
+
---------------------------
|
|
153
|
+
|
|
154
|
+
You can exclude files from mutation in `setup.cfg`:
|
|
155
|
+
|
|
156
|
+
.. code-block::
|
|
157
|
+
|
|
158
|
+
do_not_mutate=
|
|
159
|
+
*__tests.py
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
Whitelisting
|
|
163
|
+
------------
|
|
164
|
+
|
|
165
|
+
You can mark lines like this:
|
|
166
|
+
|
|
167
|
+
.. code-block:: python
|
|
168
|
+
|
|
169
|
+
some_code_here() # pragma: no mutate
|
|
170
|
+
|
|
171
|
+
to stop mutation on those lines. Some cases we've found where you need to
|
|
172
|
+
whitelist lines are:
|
|
173
|
+
|
|
174
|
+
- The version string on your library. You really shouldn't have a test for this :P
|
|
175
|
+
- Optimizing break instead of continue. The code runs fine when mutating break
|
|
176
|
+
to continue, but it's slower.
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
Example mutations
|
|
180
|
+
-----------------
|
|
181
|
+
|
|
182
|
+
- Integer literals are changed by adding 1. So 0 becomes 1, 5 becomes 6, etc.
|
|
183
|
+
- `<` is changed to `<=`
|
|
184
|
+
- break is changed to continue and vice versa
|
|
185
|
+
|
|
186
|
+
In general the idea is that the mutations should be as subtle as possible.
|
|
187
|
+
See `__init__.py` for the full list.
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
Workflow
|
|
191
|
+
--------
|
|
192
|
+
|
|
193
|
+
This section describes how to work with mutmut to enhance your test suite.
|
|
194
|
+
|
|
195
|
+
1. Run mutmut with `mutmut run`. A full run is preferred but if you're just
|
|
196
|
+
getting started you can exit in the middle and start working with what you
|
|
197
|
+
have found so far.
|
|
198
|
+
2. Show the mutants with `mutmut browse`
|
|
199
|
+
3. Find a mutant you want to work on and write a test to try to kill it.
|
|
200
|
+
4. Press `r` to rerun the mutant and see if you successfully managed to kill it.
|
|
201
|
+
|
|
202
|
+
Mutmut keeps the data of what it has done and the mutants in the `mutants/`
|
|
203
|
+
directory.If you want to make sure you run a full mutmut run you can delete
|
|
204
|
+
this directory to start from scratch.
|
mutmut-3.0.0/README.rst
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
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
|
+
|
|
26
|
+
If you want to mutate code outside of functions, you can try using mutmut 2,
|
|
27
|
+
which has a different execution model than mutmut 3+.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Requirements
|
|
31
|
+
------------
|
|
32
|
+
|
|
33
|
+
Mutmut must be run on a system with `fork` support. This means that if you want
|
|
34
|
+
to run on windows, you must run inside WSL.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
Install and run
|
|
39
|
+
---------------
|
|
40
|
+
|
|
41
|
+
You can get started with a simple:
|
|
42
|
+
|
|
43
|
+
.. code-block:: console
|
|
44
|
+
|
|
45
|
+
pip install mutmut
|
|
46
|
+
mutmut run
|
|
47
|
+
|
|
48
|
+
This will by run pytest on tests in the "tests" or "test" folder and
|
|
49
|
+
it will try to figure out where the code to mutate is.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
.. code-block:: ini
|
|
54
|
+
|
|
55
|
+
[mutmut]
|
|
56
|
+
paths_to_mutate=src/
|
|
57
|
+
tests_dir=tests/
|
|
58
|
+
|
|
59
|
+
You can stop the mutation run at any time and mutmut will restart where you
|
|
60
|
+
left off. It will continue where it left off, and re-test functions that were
|
|
61
|
+
modified since last run.
|
|
62
|
+
|
|
63
|
+
To work with the results, use `mutmut browse` where you can see the mutants,
|
|
64
|
+
retest them when you've updated your tests.
|
|
65
|
+
|
|
66
|
+
You can also write a mutant to disk from the `browse` interface, or via
|
|
67
|
+
`mutmut apply <mutant>`. You should **REALLY** have the file you mutate under
|
|
68
|
+
source code control and committed before you apply a mutant!
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
Wildcards for testing mutants
|
|
72
|
+
-----------------------------
|
|
73
|
+
|
|
74
|
+
Unix filename pattern matching style on mutants is supported. Example:
|
|
75
|
+
|
|
76
|
+
.. code-block:: console
|
|
77
|
+
|
|
78
|
+
mutmut run "my_module*"
|
|
79
|
+
mutmut run "my_module.my_function*"
|
|
80
|
+
|
|
81
|
+
In the `browse` TUI you can press `f` to retest a function, and `m` to retest
|
|
82
|
+
an entire module.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
"also copy" files
|
|
86
|
+
-----------------
|
|
87
|
+
|
|
88
|
+
To run the full test suite some files are often needed above the tests and the
|
|
89
|
+
source. You can configure to copy extra files that you need by adding
|
|
90
|
+
directories and files to `also_copy` in your `setup.cfg`:
|
|
91
|
+
|
|
92
|
+
.. code-block:: ini
|
|
93
|
+
|
|
94
|
+
also_copy=
|
|
95
|
+
iommi/snapshots/
|
|
96
|
+
conftest.py
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
Limit stack depth
|
|
100
|
+
-----------------
|
|
101
|
+
|
|
102
|
+
In big code bases some functions are called incidentally by huge swaths of the
|
|
103
|
+
codebase, but you really don't want tests that hit those executions to count
|
|
104
|
+
for mutation testing purposes. Incidentally tested functions lead to slow
|
|
105
|
+
mutation testing as hundreds of tests can be checked for things that should
|
|
106
|
+
have clean and fast unit tests, and it leads to bad test suites as any
|
|
107
|
+
introduced bug in those base functions will lead to many tests that fail which
|
|
108
|
+
are hard to understand how they relate to the function with the change.
|
|
109
|
+
|
|
110
|
+
You can configure mutmut to only count a test as being relevant for a function
|
|
111
|
+
if the stack depth from the test to the function is below some limit. In your
|
|
112
|
+
`setup.cfg` add:
|
|
113
|
+
|
|
114
|
+
.. code-block:: ini
|
|
115
|
+
|
|
116
|
+
max_stack_depth=8
|
|
117
|
+
|
|
118
|
+
A lower value will increase mutation speed and lead to more localized tests,
|
|
119
|
+
but will also lead to more surviving mutants that would otherwise have been
|
|
120
|
+
caught.
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
Exclude files from mutation
|
|
124
|
+
---------------------------
|
|
125
|
+
|
|
126
|
+
You can exclude files from mutation in `setup.cfg`:
|
|
127
|
+
|
|
128
|
+
.. code-block::
|
|
129
|
+
|
|
130
|
+
do_not_mutate=
|
|
131
|
+
*__tests.py
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
Whitelisting
|
|
135
|
+
------------
|
|
136
|
+
|
|
137
|
+
You can mark lines like this:
|
|
138
|
+
|
|
139
|
+
.. code-block:: python
|
|
140
|
+
|
|
141
|
+
some_code_here() # pragma: no mutate
|
|
142
|
+
|
|
143
|
+
to stop mutation on those lines. Some cases we've found where you need to
|
|
144
|
+
whitelist lines are:
|
|
145
|
+
|
|
146
|
+
- The version string on your library. You really shouldn't have a test for this :P
|
|
147
|
+
- Optimizing break instead of continue. The code runs fine when mutating break
|
|
148
|
+
to continue, but it's slower.
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
Example mutations
|
|
152
|
+
-----------------
|
|
153
|
+
|
|
154
|
+
- Integer literals are changed by adding 1. So 0 becomes 1, 5 becomes 6, etc.
|
|
155
|
+
- `<` is changed to `<=`
|
|
156
|
+
- break is changed to continue and vice versa
|
|
157
|
+
|
|
158
|
+
In general the idea is that the mutations should be as subtle as possible.
|
|
159
|
+
See `__init__.py` for the full list.
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
Workflow
|
|
163
|
+
--------
|
|
164
|
+
|
|
165
|
+
This section describes how to work with mutmut to enhance your test suite.
|
|
166
|
+
|
|
167
|
+
1. Run mutmut with `mutmut run`. A full run is preferred but if you're just
|
|
168
|
+
getting started you can exit in the middle and start working with what you
|
|
169
|
+
have found so far.
|
|
170
|
+
2. Show the mutants with `mutmut browse`
|
|
171
|
+
3. Find a mutant you want to work on and write a test to try to kill it.
|
|
172
|
+
4. Press `r` to rerun the mutant and see if you successfully managed to kill it.
|
|
173
|
+
|
|
174
|
+
Mutmut keeps the data of what it has done and the mutants in the `mutants/`
|
|
175
|
+
directory.If you want to make sure you run a full mutmut run you can delete
|
|
176
|
+
this directory to start from scratch.
|