def test_existing_input_paths(
    unique_filename_maker_kwargs, existing_filepaths
):
    """test baseline vs parallel with existing input paths"""

    with tempfile.TemporaryDirectory() as tmp_dir:
        for existing_filepath in existing_filepaths:
            with open(
                os.path.join(tmp_dir, existing_filepath),
                "w",
                encoding="utf-8",
            ):
                ...

        unique_filename_maker_kwargs["output_dir"] = tmp_dir

        filename_maker = focu.UniqueFilenameMaker(
            **unique_filename_maker_kwargs
        )

        # This is the original behavior of `get_output_path``, used as the
        # baseline.

        random.shuffle(expected_input_paths := INPUT_PATHS[:])

        expected = list(
            map(filename_maker.get_output_path, expected_input_paths)
        )

        # Run multiple workers with their own instance UniqueFilenameMaker and
        # aggregate the calls to `get_output_path`.
        with multiprocessing.Pool(
            processes=4,
            initializer=init_process,
            initargs=(unique_filename_maker_kwargs | {"ppid": os.getpid()},),
        ) as pool:
            random.shuffle(actual_input_paths := INPUT_PATHS[:])

            actual = list(
                pool.imap_unordered(
                    process_get_output_path, actual_input_paths
                )
            )

        # Normalize results
        ignore_exts = unique_filename_maker_kwargs.get("ignore_exts") is True
        for output_paths in (expected, actual):
            for idx, output_path in enumerate(output_paths):
                # The numbering should be the same but the extension might be
                #  different as the order called isn't ensured.
                if ignore_exts:
                    output_path, _ = os.path.splitext(output_path)

                output_paths[idx] = output_path

        assert sorted(expected) == sorted(actual)
test baseline vs parallel with existing input paths
tests/unittests/utils/test_unique_filename_maker.py