Plant a mutant in a Python file whose lines end in CRLF
CI / tests (pull_request) Successful in 4m8s

This commit is contained in:
2026-11-23 23:14:36 +01:00
parent fb3e526989
commit 4620365931
4 changed files with 41 additions and 4 deletions
+10
View File
@@ -29,6 +29,16 @@ class MutatedTest(unittest.TestCase):
self.assertEqual(mutated(b"a\nb + c", Mutant("calc.go", 2, "x", (b"b + c",), (b"b - c",))), b"a\nb - c")
self.assertIsNone(mutated(b"a\nb + c", Mutant("calc.go", 3, "x", (b"b + c",), (b"b - c",))))
def test_a_file_with_crlf_line_ends_matches_the_lines_without_their_cr_and_gets_the_mutants_lines_with_one(self):
source = b"a\r\n\tb + c\r\n\td,\r\n\te\r\n"
self.assertEqual(mutated(source, Mutant("calc.py", 2, "x", (b"\tb + c", b"\td,"), (b"\tb", b"\t- c", b"\td"))), b"a\r\n\tb\r\n\t- c\r\n\td\r\n\te\r\n")
self.assertEqual(mutated(source, Mutant("calc.py", 3, "x", (), (b"\tf,",))), b"a\r\n\tb + c\r\n\tf,\r\n\td,\r\n\te\r\n")
self.assertEqual(mutated(source, Mutant("calc.py", 3, "x", (b"\td,",), ())), b"a\r\n\tb + c\r\n\te\r\n")
self.assertIsNone(mutated(source, Mutant("calc.py", 2, "x", (b"\tb + c\r",), (b"z",))))
def test_the_last_line_of_a_crlf_file_has_no_line_end_to_take(self):
self.assertEqual(mutated(b"a\r\nb + c", Mutant("calc.py", 2, "x", (b"b + c",), (b"b - c",))), b"a\r\nb - c")
class LineAtHeadTest(unittest.TestCase):
# Lines 3 and 4 became one, two lines went in after line 9, and line 20 went.