@@ -40,6 +40,34 @@ def mutated_module(source: str) -> str:
4040 # ('break', 'continue'), # probably a bad idea. Can introduce infinite loops.
4141 ('break' , 'return' ),
4242 ('continue' , 'break' ),
43+ ('a.lower()' , 'a.upper()' ),
44+ ('a.upper()' , 'a.lower()' ),
45+ ('a.b.lower()' , 'a.b.upper()' ),
46+ ('a.b.upper()' , 'a.b.lower()' ),
47+ ('a.lstrip("!")' , ['a.rstrip("!")' , 'a.lstrip("XX!XX")' , 'a.lstrip(None)' ]),
48+ ('a.rstrip("!")' , ['a.lstrip("!")' , 'a.rstrip("XX!XX")' , 'a.rstrip(None)' ]),
49+ ('a.find("!")' , ['a.rfind("!")' , 'a.find("XX!XX")' , 'a.find(None)' ]),
50+ ('a.rfind("!")' , ['a.find("!")' , 'a.rfind("XX!XX")' , 'a.rfind(None)' ]),
51+ ('a.ljust(10, "+")' , [
52+ 'a.ljust("+")' , 'a.ljust(10, "XX+XX")' ,
53+ 'a.ljust(10, )' , 'a.ljust(10, None)' ,
54+ 'a.ljust(11, "+")' , 'a.ljust(None, "+")' ,
55+ 'a.rjust(10, "+")'
56+ ]),
57+ ('a.rjust(10, "+")' , [
58+ 'a.ljust(10, "+")' , 'a.rjust("+")' ,
59+ 'a.rjust(10, "XX+XX")' , 'a.rjust(10, )' ,
60+ 'a.rjust(10, None)' , 'a.rjust(11, "+")' ,
61+ 'a.rjust(None, "+")'
62+ ]),
63+ ('a.index("+")' , ['a.rindex("+")' , 'a.index("XX+XX")' , 'a.index(None)' ]),
64+ ('a.rindex("+")' , ['a.index("+")' , 'a.rindex("XX+XX")' , 'a.rindex(None)' ]),
65+ ('a.split()' , 'a.rsplit()' ),
66+ ('a.rsplit()' , 'a.split()' ),
67+ ('a.removeprefix("+")' , ['a.removesuffix("+")' , 'a.removeprefix("XX+XX")' , 'a.removeprefix(None)' ]),
68+ ('a.removesuffix("+")' , ['a.removeprefix("+")' , 'a.removesuffix("XX+XX")' , 'a.removesuffix(None)' ]),
69+ ('a.partition("++")' , ['a.rpartition("++")' , 'a.partition("XX++XX")' , 'a.partition(None)' ]),
70+ ('a.rpartition("++")' , ['a.partition("++")' , 'a.rpartition("XX++XX")' , 'a.rpartition(None)' ]),
4371 ('a(b)' , 'a(None)' ),
4472 ("dict(a=None)" , ["dict(aXX=None)" ]),
4573 ("dict(a=b)" , ["dict(aXX=b)" , 'dict(a=None)' ]),
@@ -235,15 +263,15 @@ def xǁFooǁmember__mutmut_1(self):
235263
236264
237265def test_function_with_annotation ():
238- source = "def capitalize(s : str):\n return s[0].upper () + s[1:] if s else s\n " .strip ()
266+ source = "def capitalize(s : str):\n return s[0].title () + s[1:] if s else s\n " .strip ()
239267
240268 mutated_code = mutated_module (source )
241269 print (mutated_code )
242270
243271 expected_defs = [
244- 'def x_capitalize__mutmut_1(s : str):\n return s[1].upper () + s[1:] if s else s' ,
245- 'def x_capitalize__mutmut_2(s : str):\n return s[0].upper () - s[1:] if s else s' ,
246- 'def x_capitalize__mutmut_3(s : str):\n return s[0].upper () + s[2:] if s else s' ,
272+ 'def x_capitalize__mutmut_1(s : str):\n return s[1].title () + s[1:] if s else s' ,
273+ 'def x_capitalize__mutmut_2(s : str):\n return s[0].title () - s[1:] if s else s' ,
274+ 'def x_capitalize__mutmut_3(s : str):\n return s[0].title () + s[2:] if s else s' ,
247275 ]
248276
249277 for expected in expected_defs :
0 commit comments