from pathlib import Path


def broken_config(tmp_path):
    """
    Writes a improperly formatted config.yml file into the directory
    broken_config.
    """

    # Create directory for the config (to avoid messing up the config
    # in tmp_path used by other tests)
    dir = Path(tmp_path, "broken_config")
    dir.mkdir()
    configpath = Path(dir, "config.yml")

    # write broken file (we can't use yaml / ruamel for this, because
    # it would throw an error writing the file)
    # The broken line is the *.csv without quotes
    with open(configpath, "w") as f:
        f.write("files_to_ignore:\n")
        f.write("- .DS_Store\n")
        f.write("- .ipynb_checkpoints\n")
        f.write("- *.csv\n")

    return dir