import pathlib


def nonexistent_file(tmpdir, request):
    """Return a path to an empty config file.
    Remove the file when a test is finished with it.
    """
    data_dir = pathlib.Path(str(tmpdir))
    nonexistent = data_dir.joinpath('nonexistent')
    if nonexistent.exists():
        nonexistent.unlink()

    def tearDown():
        if nonexistent.exists():
            nonexistent.unlink()

    request.addfinalizer(tearDown)
    return nonexistent