Comments (13)
True, imports that are broken are for static analysis tools to handle. I'll fix it.
from mutmut.
Well I agree this mutant is bad but if your test suite survives a syntax error something else is wrong here. If you apply this mutant to your source code your test suite should fail. Does it?
from mutmut.
My tests fail if I apply this mutant manually and run my suite directly from pytest:
E def except_to_bool(_func=None, /, exc=Exception, to=False):
E ^
E SyntaxError: invalid syntax
but they do not fail if mutant is applied by mutmut and suit is run by it:
(exceptbool) xxx@xxx:~/projects/exceptbool$ mutmut run
- Mutation testing starting -
These are the steps:
1. A full test suite run will be made to make sure we
can run the tests successfully and we know how long
it takes (to detect infinite loops for example)
2. Mutants will be generated and checked
Mutants are written to the cache in the .mutmut-cache
directory. Print found mutants with `mutmut results`.
Legend for output:
π Killed mutants. The goal is for everything to end up in this bucket.
β° Timeout. Test suite took 10 times as long as the baseline so were killed.
π€ Suspicious. Tests took a long time, but not long enough to be fatal.
π Survived. This means your tests needs to be expanded.
1. Using cached time for baseline tests, to run baseline again delete the cache file
2. Checking mutants
β 6/6 π 5 β° 0 π€ 0 π 1
from mutmut.
That is strange. Can you supply the code?
from mutmut.
https://github.com/konrad-kocik/exceptbool
Tested method can be found here: exceptbool/exceptbool.py -> except_to_bool
Tests can be found here: tests/test_execeptbool.py
Setup your virtualenv with: pip install -r requirements_dev.txt
from mutmut.
I agree this is a bug, but it's a performance issue mostly. When I run mutmut on exceptbool I get just one surviving mutant like you get but it's this one:
>>mutmut show 3
--- exceptbool/exceptbool.py
+++ exceptbool/exceptbool.py
@@ -18,7 +18,7 @@
:type: bool
"""
def decorator(func):
- @wraps(func)
+
def wrapper(*args, **kwargs):
try:
func(*args, **kwargs)
You're applying a mutant that was killed:
> mutmut show 1
--- exceptbool/exceptbool.py
+++ exceptbool/exceptbool.py
@@ -1,7 +1,7 @@
from functools import wraps
-def except_to_bool(_func=None, *, exc=Exception, to=False):
+def except_to_bool(_func=None, /, exc=Exception, to=False):
"""
Makes decorated function return bool instead of raising an exception by
converting given exception(s) into given bool value.
If you run just this mutant with mutmut run 1
it will report this as killed.
from mutmut.
from mutmut.
They will not ;)
from mutmut.
Well, you were right, of course :) I needed to extend my test suite to kill that mutant. But this is exactly why I wanted to perform mutation tests in the first place! So thank you for that.
Final question: will you still try to solve this problem with transforming * into / in context of keyword arguments enforcement? Or will it stay that way?
from mutmut.
It should be fixed yes. It's a performance issue (albeit a small one) if nothing else.
from mutmut.
BTW, with version 1.3.1, I have a survived mutant like this:
$ mutmut show
To apply a mutant on disk:
mutmut apply <id>
To show a mutant:
mutmut show <id>
Survived π (9)
---- src/templite.py (8) ----
10, 27, 35, 43, 44, 56, 106, 150
---- src/__init__.py (1) ----
153
$ mutmut show 153
--- src/__init__.py
+++ src/__init__.py
@@ -1,2 +1,2 @@
-from .templite import *
+from .templite import /
I've laid out my package wrong, which is why this survives the test suite, but it still is not a valid mutation.
from mutmut.
Maybe I should have a special pass for finding files that can survive syntax errors because this stuff keeps happening :P
Yea, that should definitely be fixed.
from mutmut.
Maybe we should skip mutating any import
lines.
Is there a way to detect lines defining import
and from foo import bar
statements within a parso.python.tree
. If so we could add a rule to skip mutating these lines. I see no real value in messing up imports for mutation testing, it seems much too high level error injection to validate any real unit tests.
from mutmut.
Related Issues (20)
- Incorrect retrieval of mutation cached status HOT 3
- Suport to python 3.10 HOT 1
- IndexError: tuple index out of range when running `mutmut results` HOT 3
- html command missing from --help but included when no command supplied
- failing test run counts as successful HOT 2
- Timeout Mechanism Not Working HOT 2
- Some results missing from html report HOT 6
- `mutmut run 5` unintuitively does not schedule if cached
- Update mutmut cache directly after r
- Modifying mutmut cache directly HOT 2
- Pony throws IndexError on results command HOT 2
- 2.4.3 and 2.4.4 release are not tagged in repo
- Mutate str methods? HOT 1
- `mutmut show --all` flag
- Issue with mutmut mutation in presence of type hints HOT 3
- Invalid mutations involving positional-only and keyword-only arguments HOT 1
- Setting the --no-progress flag also removes output from a run.
- [Feature Request] Random Sampling of Mutations HOT 3
- Support new python's versions HOT 1
- TypeError: can only concatenate str (not "list") to str in mutmut 2.4.4 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mutmut.