| 1 |
"""Mutate Comparison Operators.""" |
|
| 2 | ||
| 3 |
from __future__ import annotations |
|
| 4 | ||
| 5 |
import ast |
|
| 6 |
import re |
|
| 7 |
from copy import deepcopy |
|
| 8 |
from typing import ClassVar |
|
| 9 | ||
| 10 |
from poodle.data_types import FileMutation, Mutator |
|
| 11 | ||
| 12 | ||
| 13 |
class ComparisonMutator(ast.NodeVisitor, Mutator): |
|
| 14 |
"""Mutate Comparison Operators.""" |
|
| 15 | ||
| 16 |
# https://docs.python.org/3/library/ast.html#ast.Compare |
|
| 17 |
# https://www.w3schools.com/python/python_operators.asp |
|
| 18 |
# ast.Eq == |
|
| 19 |
# ast.NotEq != |
|
| 20 |
# ast.Lt < |
|
| 21 |
# ast.LtE <= |
|
| 22 |
# ast.Gt > |
|
| 23 |
# ast.GtE >= |
|
| 24 |
# ast.Is is |
|
| 25 |
# ast.IsNot is not |
|
| 26 |
# ast.In in |
|
| 27 |
# ast.NotIn not in |
|
| 28 |
# ast.Or or |
|
| 29 |
# ast.And and |
|
| 30 | ||
| 31 |
type_map: ClassVar[dict[type, list[type]]] = {
|
|
| 32 |
ast.Eq: [ast.NotEq], |
|
| 33 |
ast.NotEq: [ast.Eq], |
|
| 34 |
ast.Lt: [ast.GtE, ast.LtE], |
|
| 35 |
ast.LtE: [ast.Gt, ast.Lt], |
|
| 36 |
ast.Gt: [ast.LtE, ast.GtE], |
|
| 37 |
ast.GtE: [ast.Lt, ast.Gt], |
|
| 38 |
ast.Is: [ast.IsNot], |
|
| 39 |
ast.IsNot: [ast.Is], |
|
| 40 |
ast.In: [ast.NotIn], |
|
| 41 |
ast.NotIn: [ast.In], |
|
| 42 |
ast.Or: [ast.And], |
|
| 43 |
ast.And: [ast.Or], |
|
| 44 |
} |
|
| 45 | ||
| ▸ | 46 |
mutator_name = "Compare" |
|
Status: Mutant Found Mutator Name: String Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:46
@@ -43,7 +43,7 @@
ast.And: [ast.Or],
}
- mutator_name = "Compare"
+ mutator_name = 'XXCompareXX'
def __init__(self, *args, **kwargs) -> None:
"""Initialize and read settings."""
|
||
| 47 | ||
| 48 |
def __init__(self, *args, **kwargs) -> None: |
|
| 49 |
"""Initialize and read settings.""" |
|
| ▸ | 50 |
super().__init__(*args, **kwargs) |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:50
@@ -47,7 +47,7 @@
def __init__(self, *args, **kwargs) -> None:
"""Initialize and read settings."""
- super().__init__(*args, **kwargs)
+ None
self.mutants: list[FileMutation] = []
self.filter_patterns: list[str] = [
|
||
| 51 |
self.mutants: list[FileMutation] = [] |
|
| 52 | ||
| 53 |
self.filter_patterns: list[str] = [ |
|
| ▸ | 54 |
r"__name__ == '__main__'", |
|
Status: Mutant Found Mutator Name: String Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:54
@@ -51,7 +51,7 @@
self.mutants: list[FileMutation] = []
self.filter_patterns: list[str] = [
- r"__name__ == '__main__'",
+ "XX__name__ == '__main__'XX",
]
self.filter_patterns += self.config.mutator_opts.get("compare_filters", [])
|
||
| 55 |
] |
|
| 56 | ||
| ▸ | 57 |
self.filter_patterns += self.config.mutator_opts.get("compare_filters", [])
|
|
Status: Mutant Found Mutator Name: AugAssign Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:57
@@ -54,7 +54,7 @@
r"__name__ == '__main__'",
]
- self.filter_patterns += self.config.mutator_opts.get("compare_filters", [])
+ self.filter_patterns = self.config.mutator_opts.get('compare_filters', [])
def create_mutations(self, parsed_ast: ast.Module, *_, **__) -> list[FileMutation]:
"""Visit all Comparisons and return created mutants."""
Status: Mutant Found Mutator Name: AugAssign Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:57
@@ -54,7 +54,7 @@
r"__name__ == '__main__'",
]
- self.filter_patterns += self.config.mutator_opts.get("compare_filters", [])
+ self.filter_patterns -= self.config.mutator_opts.get('compare_filters', [])
def create_mutations(self, parsed_ast: ast.Module, *_, **__) -> list[FileMutation]:
"""Visit all Comparisons and return created mutants."""
Status: Mutant Found Mutator Name: AugAssign Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:57
@@ -54,7 +54,7 @@
r"__name__ == '__main__'",
]
- self.filter_patterns += self.config.mutator_opts.get("compare_filters", [])
+ self.filter_patterns *= self.config.mutator_opts.get('compare_filters', [])
def create_mutations(self, parsed_ast: ast.Module, *_, **__) -> list[FileMutation]:
"""Visit all Comparisons and return created mutants."""
Status: Mutant Found Mutator Name: String Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:57
@@ -54,7 +54,7 @@
r"__name__ == '__main__'",
]
- self.filter_patterns += self.config.mutator_opts.get("compare_filters", [])
+ self.filter_patterns += self.config.mutator_opts.get('XXcompare_filtersXX', [])
def create_mutations(self, parsed_ast: ast.Module, *_, **__) -> list[FileMutation]:
"""Visit all Comparisons and return created mutants."""
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:57
@@ -54,7 +54,7 @@
r"__name__ == '__main__'",
]
- self.filter_patterns += self.config.mutator_opts.get("compare_filters", [])
+ self.filter_patterns += None
def create_mutations(self, parsed_ast: ast.Module, *_, **__) -> list[FileMutation]:
"""Visit all Comparisons and return created mutants."""
|
||
| 58 | ||
| 59 |
def create_mutations(self, parsed_ast: ast.Module, *_, **__) -> list[FileMutation]: |
|
| 60 |
"""Visit all Comparisons and return created mutants.""" |
|
| 61 |
self.mutants = [] |
|
| ▸ | 62 |
self.add_parent_attr(parsed_ast) |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:62
@@ -59,7 +59,7 @@
def create_mutations(self, parsed_ast: ast.Module, *_, **__) -> list[FileMutation]:
"""Visit all Comparisons and return created mutants."""
self.mutants = []
- self.add_parent_attr(parsed_ast)
+ None
self.visit(parsed_ast)
return self.mutants
|
||
| ▸ | 63 |
self.visit(parsed_ast) |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:63
@@ -60,7 +60,7 @@
"""Visit all Comparisons and return created mutants."""
self.mutants = []
self.add_parent_attr(parsed_ast)
- self.visit(parsed_ast)
+ None
return self.mutants
def visit_Compare(self, node: ast.Compare) -> None:
|
||
| ▸ | 64 |
return self.mutants |
|
Status: Mutant Found Mutator Name: Return Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:64
@@ -61,7 +61,7 @@
self.mutants = []
self.add_parent_attr(parsed_ast)
self.visit(parsed_ast)
- return self.mutants
+ return None
def visit_Compare(self, node: ast.Compare) -> None:
"""Identify replacement Operations and create Mutants."""
|
||
| 65 | ||
| 66 |
def visit_Compare(self, node: ast.Compare) -> None: |
|
| 67 |
"""Identify replacement Operations and create Mutants.""" |
|
| ▸ | 68 |
text = ast.unparse(node) |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:68
@@ -65,7 +65,7 @@
def visit_Compare(self, node: ast.Compare) -> None:
"""Identify replacement Operations and create Mutants."""
- text = ast.unparse(node)
+ text = None
for pattern in self.filter_patterns:
if re.match(pattern, text):
return
|
||
| 69 |
for pattern in self.filter_patterns: |
|
| ▸ | 70 |
if re.match(pattern, text): |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:70
@@ -67,7 +67,7 @@
"""Identify replacement Operations and create Mutants."""
text = ast.unparse(node)
for pattern in self.filter_patterns:
- if re.match(pattern, text):
+ if None:
return
for idx, op in enumerate(node.ops):
|
||
| 71 |
return |
|
| 72 | ||
| ▸ | 73 |
for idx, op in enumerate(node.ops): |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:73
@@ -70,7 +70,7 @@
if re.match(pattern, text):
return
- for idx, op in enumerate(node.ops):
+ for idx, op in None:
for new_op in self.type_map[type(op)]:
mut = deepcopy(node)
mut.ops[idx] = new_op()
|
||
| ▸ | 74 |
for new_op in self.type_map[type(op)]: |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:74
@@ -71,7 +71,7 @@
return
for idx, op in enumerate(node.ops):
- for new_op in self.type_map[type(op)]:
+ for new_op in self.type_map[None]:
mut = deepcopy(node)
mut.ops[idx] = new_op()
self.mutants.append(self.create_file_mutation(node, ast.unparse(mut)))
Status: Mutant Found Mutator Name: DictArray Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:74
@@ -71,7 +71,7 @@
return
for idx, op in enumerate(node.ops):
- for new_op in self.type_map[type(op)]:
+ for new_op in None:
mut = deepcopy(node)
mut.ops[idx] = new_op()
self.mutants.append(self.create_file_mutation(node, ast.unparse(mut)))
|
||
| ▸ | 75 |
mut = deepcopy(node) |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:75
@@ -72,7 +72,7 @@
for idx, op in enumerate(node.ops):
for new_op in self.type_map[type(op)]:
- mut = deepcopy(node)
+ mut = None
mut.ops[idx] = new_op()
self.mutants.append(self.create_file_mutation(node, ast.unparse(mut)))
|
||
| ▸ | 76 |
mut.ops[idx] = new_op() |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:76
@@ -73,7 +73,7 @@
for idx, op in enumerate(node.ops):
for new_op in self.type_map[type(op)]:
mut = deepcopy(node)
- mut.ops[idx] = new_op()
+ mut.ops[idx] = None
self.mutants.append(self.create_file_mutation(node, ast.unparse(mut)))
def visit_BoolOp(self, node: ast.BoolOp) -> None:
Status: Mutant Found Mutator Name: DictArray Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:76
@@ -73,7 +73,7 @@
for idx, op in enumerate(node.ops):
for new_op in self.type_map[type(op)]:
mut = deepcopy(node)
- mut.ops[idx] = new_op()
+ None = new_op()
self.mutants.append(self.create_file_mutation(node, ast.unparse(mut)))
def visit_BoolOp(self, node: ast.BoolOp) -> None:
|
||
| ▸ | 77 |
self.mutants.append(self.create_file_mutation(node, ast.unparse(mut))) |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:77
@@ -74,7 +74,7 @@
for new_op in self.type_map[type(op)]:
mut = deepcopy(node)
mut.ops[idx] = new_op()
- self.mutants.append(self.create_file_mutation(node, ast.unparse(mut)))
+ None
def visit_BoolOp(self, node: ast.BoolOp) -> None:
"""Identify replacement Operations and create Mutants."""
|
||
| 78 | ||
| 79 |
def visit_BoolOp(self, node: ast.BoolOp) -> None: |
|
| 80 |
"""Identify replacement Operations and create Mutants.""" |
|
| ▸ | 81 |
if self.is_annotation(node) or type(node.op) not in self.type_map: |
|
Status: Mutant Found Mutator Name: Compare Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:81
@@ -78,7 +78,7 @@
def visit_BoolOp(self, node: ast.BoolOp) -> None:
"""Identify replacement Operations and create Mutants."""
- if self.is_annotation(node) or type(node.op) not in self.type_map:
+ if self.is_annotation(node) and type(node.op) not in self.type_map:
return
text = ast.unparse(node)
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:81
@@ -78,7 +78,7 @@
def visit_BoolOp(self, node: ast.BoolOp) -> None:
"""Identify replacement Operations and create Mutants."""
- if self.is_annotation(node) or type(node.op) not in self.type_map:
+ if None or type(node.op) not in self.type_map:
return
text = ast.unparse(node)
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:81
@@ -78,7 +78,7 @@
def visit_BoolOp(self, node: ast.BoolOp) -> None:
"""Identify replacement Operations and create Mutants."""
- if self.is_annotation(node) or type(node.op) not in self.type_map:
+ if self.is_annotation(node) or None not in self.type_map:
return
text = ast.unparse(node)
|
||
| 82 |
return |
|
| 83 | ||
| ▸ | 84 |
text = ast.unparse(node) |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:84
@@ -81,7 +81,7 @@
if self.is_annotation(node) or type(node.op) not in self.type_map:
return
- text = ast.unparse(node)
+ text = None
for pattern in self.filter_patterns:
if re.match(pattern, text):
return
|
||
| 85 |
for pattern in self.filter_patterns: |
|
| ▸ | 86 |
if re.match(pattern, text): |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:86
@@ -83,7 +83,7 @@
text = ast.unparse(node)
for pattern in self.filter_patterns:
- if re.match(pattern, text):
+ if None:
return
for new_op in self.type_map[type(node.op)]:
|
||
| 87 |
return |
|
| 88 | ||
| ▸ | 89 |
for new_op in self.type_map[type(node.op)]: |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:89
@@ -86,7 +86,7 @@
if re.match(pattern, text):
return
- for new_op in self.type_map[type(node.op)]:
+ for new_op in self.type_map[None]:
mut = deepcopy(node)
mut.op = new_op()
self.mutants.append(self.create_file_mutation(node, ast.unparse(mut)))
Status: Mutant Found Mutator Name: DictArray Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:89
@@ -86,7 +86,7 @@
if re.match(pattern, text):
return
- for new_op in self.type_map[type(node.op)]:
+ for new_op in None:
mut = deepcopy(node)
mut.op = new_op()
self.mutants.append(self.create_file_mutation(node, ast.unparse(mut)))
|
||
| ▸ | 90 |
mut = deepcopy(node) |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:90
@@ -87,6 +87,6 @@
return
for new_op in self.type_map[type(node.op)]:
- mut = deepcopy(node)
+ mut = None
mut.op = new_op()
self.mutants.append(self.create_file_mutation(node, ast.unparse(mut)))
|
||
| ▸ | 91 |
mut.op = new_op() |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:91
@@ -88,5 +88,5 @@
for new_op in self.type_map[type(node.op)]:
mut = deepcopy(node)
- mut.op = new_op()
+ mut.op = None
self.mutants.append(self.create_file_mutation(node, ast.unparse(mut)))
|
||
| ▸ | 92 |
self.mutants.append(self.create_file_mutation(node, ast.unparse(mut))) |
|
Status: Mutant Found Mutator Name: FuncCall Unified Diff: --- src\poodle\mutators\compare.py
+++ [Mutant] src\poodle\mutators\compare.py:92
@@ -89,4 +89,4 @@
for new_op in self.type_map[type(node.op)]:
mut = deepcopy(node)
mut.op = new_op()
- self.mutants.append(self.create_file_mutation(node, ast.unparse(mut)))
+ None
|