GithubHelp home page GithubHelp logo

Comments (13)

boxed avatar boxed commented on June 15, 2024 1

True, imports that are broken are for static analysis tools to handle. I'll fix it.

from mutmut.

boxed avatar boxed commented on June 15, 2024

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.

konrad-kocik avatar konrad-kocik commented on June 15, 2024

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.

boxed avatar boxed commented on June 15, 2024

That is strange. Can you supply the code?

from mutmut.

konrad-kocik avatar konrad-kocik commented on June 15, 2024

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.

boxed avatar boxed commented on June 15, 2024

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.

konrad-kocik avatar konrad-kocik commented on June 15, 2024

from mutmut.

boxed avatar boxed commented on June 15, 2024

They will not ;)

from mutmut.

konrad-kocik avatar konrad-kocik commented on June 15, 2024

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.

boxed avatar boxed commented on June 15, 2024

It should be fixed yes. It's a performance issue (albeit a small one) if nothing else.

from mutmut.

nedbat avatar nedbat commented on June 15, 2024

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.

boxed avatar boxed commented on June 15, 2024

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.

nklapste avatar nklapste commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.