Fixes for mutation testing
@@ -594,14 +594,13 @@ def sort_after(l):
to_be_moved_by_index = []
to_be_moved_by_name = defaultdict(list)
to_be_moved_last = []
- result = []
for x in l:
after = getattr(x, 'after', None)
if after is None:
unmoved.append(x)
elif after is LAST:
to_be_moved_last.append(x)
- elif type(after) == int:
+ elif isinstance(after, int):
to_be_moved_by_index.append(x)
else:
to_be_moved_by_name[x.after].append(x)
@@ -617,16 +616,20 @@ def place(x):
def traverse():
count = 0
while unmoved or to_be_moved_by_index:
- while to_be_moved_by_index and count >= to_be_moved_by_index[0].after:
+ while to_be_moved_by_index:
+ next_by_position_index = to_be_moved_by_index[0].after
+ if count < next_by_position_index: # pragma: no mutate (infinite loop when mutating < to <=)
+ break # pragma: no mutate (infinite loop when mutated to continue)
+
objects_with_index_due = place(to_be_moved_by_index.pop(0))
for x in objects_with_index_due:
yield x
- count += 1
+ count += 1 # pragma: no mutate
if unmoved:
next_unmoved_and_its_children = place(unmoved.pop(0))
for x in next_unmoved_and_its_children:
yield x
- count += 1
+ count += 1 # pragma: no mutate
for x in to_be_moved_last:
for y in place(x):
