(self, *, raises)
| 2952 | self.do_test_remove_with_mutate_root(raises=False) |
| 2953 | |
| 2954 | def do_test_remove_with_mutate_root(self, *, raises): |
| 2955 | E = ET.Element |
| 2956 | |
| 2957 | class Z(E): |
| 2958 | def __eq__(self, o): |
| 2959 | del root[0] |
| 2960 | return not raises |
| 2961 | |
| 2962 | if raises: |
| 2963 | get_checker_context = lambda: self.assertRaises(ValueError) |
| 2964 | else: |
| 2965 | get_checker_context = nullcontext |
| 2966 | |
| 2967 | # test removing R() from [U(), V()] |
| 2968 | cases = self.cases_for_remove_missing_with_mutations(E, Z) |
| 2969 | for R, U, V, description in cases: |
| 2970 | with self.subTest(description): |
| 2971 | root = E('top') |
| 2972 | root.extend([U('one'), V('two')]) |
| 2973 | with get_checker_context(): |
| 2974 | root.remove(R('missing')) |
| 2975 | |
| 2976 | # test removing root[1] (of type R) from [U(), R()] |
| 2977 | cases = self.cases_for_remove_existing_with_mutations(E, Z) |
| 2978 | for R, U, description in cases: |
| 2979 | with self.subTest(description): |
| 2980 | root = E('top') |
| 2981 | root.extend([U('one'), R('rem')]) |
| 2982 | with get_checker_context(): |
| 2983 | root.remove(root[1]) |
| 2984 | |
| 2985 | def cases_for_remove_missing_with_mutations(self, E, Z): |
| 2986 | # Cases for removing R() from [U(), V()]. |
no test coverage detected