Conversation
| def _check_methods(C, *methods): | ||
| mro = C.__mro__ | ||
| for method in methods: | ||
| for B in mro: |
There was a problem hiding this comment.
[pysnooper.utils.x__check_methods__mutmut_1] Survived mutant. Changed mro = C.__mro__ to mro = None
Why: The mutant replaces the call to C.mro with None, which makes the code always return an empty list.
How to kill: Introduce a new test that checks if C.mro is actually called and returns a non-empty list. If it does, the mutant can be killed by adding a new test case that verifies this condition.
Test:
def test_check_methods_calls_mro():
assert C.__mro__ == None
assert len(C.__mro__) > 0| for B in mro: | ||
| if method in B.__dict__: | ||
| if B.__dict__[method] is None: | ||
| return NotImplemented |
There was a problem hiding this comment.
[pysnooper.utils.x__check_methods__mutmut_2] Survived mutant. Changed if method in B.__dict__: to if method not in B.__dict__:
Why: The mutated line removes a check for whether the method is defined in a superclass before attempting to call it. This can cause the method to be called with None as the self argument, which can lead to errors or unexpected behavior.
How to kill:
Test:
def test_string_io():
from pysnooper.utils import C, methods
for method in methods:
for B in C.__mro__:
if method not in B.__dict__:
assert B.method is None| if method in B.__dict__: | ||
| if B.__dict__[method] is None: | ||
| return NotImplemented | ||
| break |
There was a problem hiding this comment.
[pysnooper.utils.x__check_methods__mutmut_3] Survived mutant. Changed if B.__dict__[method] is None: to if B.__dict__[method] is not None:
Why: The mutant survived because the condition 'if B.dict[method] is None:' was removed, making the code path that would cause the mutant to be detected less explicit.
How to kill: Add a test case that specifically tests for this condition and verifies that it is not met.
Test:
def test_string_io():
# Arrange
from pysnooper.utils import StringIO
class MyClass:
def __init__(self):
self.x = 10
def my_method(self, x):
return x + self.x
instance = MyClass()
# Act
io = StringIO()
with snoop('my_method', io):
result = instance.my_method(20)
# Assert
assert result == 30
# This test would detect the mutant because it specifically tests for the condition that would cause the mutant to be detected.
No description provided.