Plant bugs for task-bench in Python from the mutants mutmut kills
CI / tests (pull_request) Failing after 3m46s
CI / tests (pull_request) Failing after 3m46s
This commit is contained in:
@@ -15,7 +15,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from mutate_changes.changed_lines import added_lines, by_folder, not_mutated, runs, tool_for
|
||||
from mutate_changes.mutmut_tool import copy_files
|
||||
from mutate_changes.mutmut_mutants import crash_in_mutmut, function_keys, mutant_globs, mutated_line, named, statuses
|
||||
from mutate_changes.mutmut_mutants import crash_in_mutmut, function_keys, mutant_globs, mutated_lines, named, statuses
|
||||
from failure import Failure
|
||||
from mutate_changes.bare_imports import imported_by_file_name
|
||||
from test_env import isolated_env
|
||||
@@ -230,26 +230,37 @@ class MutmutMutants(unittest.TestCase):
|
||||
results = " pkg.x_f__mutmut_1: survived\n pkg.x_f__mutmut_2: no tests\n\n pkg.x_f__mutmut_3: killed\n pkg.x_f__mutmut_4:\n mutants: 4\n"
|
||||
self.assertEqual(statuses(results), {"pkg.x_f__mutmut_1": "survived", "pkg.x_f__mutmut_2": "no tests", "pkg.x_f__mutmut_3": "killed"})
|
||||
|
||||
def test_a_mutated_line_is_the_first_line_the_mutant_changes_at_its_place_in_the_source(self):
|
||||
self.assertEqual(mutated_line(SOURCE, COPY, "x_double", 1), (2, "return n / 2"))
|
||||
self.assertEqual(mutated_line(SOURCE, COPY, "xǁPtǁmoved", 1), (6, "def moved(self, by=2):"))
|
||||
self.assertEqual(mutated_line(SOURCE, COPY, "xǁPtǁmoved", 2), (7, "return self.x - by"))
|
||||
def test_the_mutated_lines_are_those_the_mutant_changes_at_their_place_in_the_source(self):
|
||||
self.assertEqual(mutated_lines(SOURCE, COPY, "x_double", 1), (2, ("\treturn n * 2",), ("\treturn n / 2",)))
|
||||
self.assertEqual(mutated_lines(SOURCE, COPY, "xǁPtǁmoved", 1), (6, ("\tdef moved(self, by=1):",), ("\tdef moved(self, by=2):",)))
|
||||
self.assertEqual(mutated_lines(SOURCE, COPY, "xǁPtǁmoved", 2), (7, ("\t\treturn self.x + by",), ("\t\treturn self.x - by",)))
|
||||
|
||||
def test_the_mutated_lines_run_from_the_first_line_that_differs_to_the_last(self):
|
||||
source = "def total(a, b):\n\tlow = min(\n\t\ta,\n\t\tb,\n\t)\n\treturn low\n"
|
||||
original = "def x_total__mutmut_orig(a, b):\n\tlow = min(\n\t\ta,\n\t\tb,\n\t)\n\treturn low\n"
|
||||
for mutant, change in (
|
||||
("\tlow = max(\n\t\tb,\n\t\ta,\n\t)\n\treturn low\n", (2, ("\tlow = min(", "\t\ta,", "\t\tb,"), ("\tlow = max(", "\t\tb,", "\t\ta,"))),
|
||||
("\tlow = min(\n\t\ta,\n\t)\n\treturn low\n", (4, ("\t\tb,",), ())),
|
||||
("\tlow = min(\n\t\ta,\n\t\tb,\n\t\tb,\n\t)\n\treturn low\n", (5, (), ("\t\tb,",))),
|
||||
):
|
||||
with self.subTest(mutant=mutant):
|
||||
self.assertEqual(mutated_lines(source, original + "def x_total__mutmut_1(a, b):\n" + mutant, "x_total", 1), change)
|
||||
|
||||
def test_a_mutant_the_copy_lacks_or_a_copy_unlike_the_source_has_no_line(self):
|
||||
self.assertIsNone(mutated_line(SOURCE, COPY, "x_double", 9))
|
||||
self.assertIsNone(mutated_line(SOURCE.replace("n * 2", "n * 2 + 1"), COPY, "x_double", 1))
|
||||
self.assertIsNone(mutated_line(SOURCE, COPY + "def x_double__mutmut_2(n):\n\treturn n * 2\n", "x_double", 2))
|
||||
self.assertIsNone(mutated_lines(SOURCE, COPY, "x_double", 9))
|
||||
self.assertIsNone(mutated_lines(SOURCE.replace("n * 2", "n * 2 + 1"), COPY, "x_double", 1))
|
||||
self.assertIsNone(mutated_lines(SOURCE, COPY + "def x_double__mutmut_2(n):\n\treturn n * 2\n", "x_double", 2))
|
||||
|
||||
def test_a_key_the_source_does_not_define_has_no_line(self):
|
||||
for key in ("x_double", "x_nope", "xǁNopeǁmoved", "xǁPtǁnope"):
|
||||
with self.subTest(key):
|
||||
self.assertIsNone(mutated_line("import os\n\n\nclass Pt:\n\tpass\n", COPY, key, 1))
|
||||
self.assertIsNone(mutated_lines("import os\n\n\nclass Pt:\n\tpass\n", COPY, key, 1))
|
||||
|
||||
def test_a_mutated_line_is_found_in_the_function_or_method_its_key_names_among_others(self):
|
||||
others = "import os\n\n\ndef triple(n):\n\treturn n * 3\n\n\nclass Q:\n\tdef moved(self, by=1):\n\t\treturn 0\n\n\n"
|
||||
self.assertEqual(mutated_line(others + SOURCE, COPY, "x_double", 1), (14, "return n / 2"))
|
||||
self.assertEqual(mutated_line(others + SOURCE, COPY, "xǁPtǁmoved", 2), (19, "return self.x - by"))
|
||||
self.assertIsNone(mutated_line(SOURCE, "def broken(:\n", "x_double", 1))
|
||||
self.assertEqual(mutated_lines(others + SOURCE, COPY, "x_double", 1), (14, ("\treturn n * 2",), ("\treturn n / 2",)))
|
||||
self.assertEqual(mutated_lines(others + SOURCE, COPY, "xǁPtǁmoved", 2), (19, ("\t\treturn self.x + by",), ("\t\treturn self.x - by",)))
|
||||
self.assertIsNone(mutated_lines(SOURCE, "def broken(:\n", "x_double", 1))
|
||||
|
||||
|
||||
class MutmutTool(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user