import collections


def _split_by_exec_group(testcases):
    """
    Split testcases into those with an execution group and those without
    one.
    """
    serial_cases = []
    parallel_cases = collections.OrderedDict()

    for testcase in testcases:
        exec_group = getattr(testcase, "execution_group", None)
        if exec_group:
            if exec_group in parallel_cases:
                parallel_cases[exec_group].append(testcase)
            else:
                parallel_cases[exec_group] = [testcase]
        else:
            serial_cases.append(testcase)

    return serial_cases, parallel_cases