def METHOD_NAME(pyi_builder, start_method, capfd):
    pyi_builder.test_script("pyi_multiprocessing_semaphore.py", app_args=[start_method])
    out, err = capfd.readouterr()
    # Print the captured output and error so that it will show up in the test output.
    sys.stderr.write(err)
    sys.stdout.write(out)
    expected = ["In main", "In subprocess"]
    assert os.linesep.join(expected) in out
    for substring in expected:
        assert out.count(substring) == 1