def METHOD_NAME(IOtest_mtz, project_name, crystal_name, dataset_name):
    """
    Test that DataSet.write_mtz() sets project/crystal/dataset names when given.
    ValueError should be raised for anything other than a string.
    """
    ds = rs.read_mtz(IOtest_mtz)
    temp = tempfile.NamedTemporaryFile(suffix=".mtz")
    if (
        not isinstance(project_name, str)
        or not isinstance(crystal_name, str)
        or not isinstance(dataset_name, str)
    ):
        with pytest.raises(ValueError):
            ds.write_mtz(
                temp.name,
                project_name=project_name,
                crystal_name=crystal_name,
                dataset_name=dataset_name,
            )
        temp.close()
        return
    else:
        ds.write_mtz(
            temp.name,
            project_name=project_name,
            crystal_name=crystal_name,
            dataset_name=dataset_name,
        )
    gemmimtz = gemmi.read_mtz_file(temp.name)
    assert gemmimtz.dataset(0).project_name == project_name
    assert gemmimtz.dataset(0).crystal_name == crystal_name
    assert gemmimtz.dataset(0).dataset_name == dataset_name
    # Clean up
    temp.close()