Skip to content

LLM Feedback#14

Open
Error1313 wants to merge 5 commits intomainfrom
test
Open

LLM Feedback#14
Error1313 wants to merge 5 commits intomainfrom
test

Conversation

@Error1313
Copy link
Collaborator

No description provided.

def _check_methods(C, *methods):
mro = C.__mro__
for method in methods:
for B in mro:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [CAMILA] reported by reviewdog 🐶
[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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [CAMILA] reported by reviewdog 🐶
[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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [CAMILA] reported by reviewdog 🐶
[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.

Repository owner deleted a comment from github-actions bot Jun 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants