Skip to content

Commit 1ec292b

Browse files
committed
Add mutation testing
1 parent 723ab37 commit 1ec292b

File tree

9 files changed

+436
-5
lines changed

9 files changed

+436
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ __pycache__
44
coverage.xml
55
junit.xml
66

7+
mutants
8+
79
# Ignore temporary experiements
810
scratch*

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,21 @@ poetry run pytest
1717
## Metrics
1818

1919
- [Codecov](https://app.codecov.io/gh/WillGibson/python-sandpit)
20+
-
21+
## Mutation testing
22+
23+
Using [mutmut](https://github.com/boxed/mutmut) as a tool to help identify gaps in our unit test coverage.
24+
25+
Every mutation that survives is a line of code that we can change without it being picked up by our unit tests.
26+
27+
To run the mutation tests:
28+
29+
```shell
30+
poetry run mutmut run
31+
```
32+
33+
The to review the mutants that survived:
34+
35+
```shell
36+
poetry run mutmut browse
37+
```

_starter_kit/src/model/__init__.py

Whitespace-only changes.

_starter_kit/tests/model/__init__.py

Whitespace-only changes.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import pytest
2-
3-
from _starter_kit.src.model.thing import Thing, ThingCantActException
2+
from _starter_kit.src.thing import Thing, ThingCantActException
43

54

65
class TestThing:

list_things/src/scattered_subset.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44

55
def scattered_subset_adding_up_to(
6-
full_set: list[int], target_sum: int, number_of_elements: int = 1
6+
full_set: list[int],
7+
target_sum: int,
8+
number_of_elements: int = 1,
79
) -> Optional[list[int]]:
810
for combination in combinations(full_set, number_of_elements):
911
if sum(combination) == target_sum:

poetry.lock

Lines changed: 399 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,24 @@ package-mode = false
66

77
[tool.poetry.dependencies]
88
python = "^3.10"
9+
typeguard = "^4.4.2"
910

1011
[tool.poetry.group.dev.dependencies]
1112
pytest = "^8.3.5"
1213
pytest-cov = "^6.1.1"
1314
pre-commit = "^4.2.0"
15+
mutmut = { git = "git@github.com:boxed/mutmut.git", branch = "main" }
1416

1517
[tool.black]
1618
line-length = 100
19+
20+
[tool.mutmut]
21+
paths_to_mutate = [
22+
"_starter_kit/src/",
23+
"fox_goose_corn/src/",
24+
"list_things/src/",
25+
"thing_rental/src/"
26+
]
27+
28+
[tool.pytest.ini_options]
29+
addopts = "--ignore mutants"

0 commit comments

Comments
 (0)