def run_writing_comparison(res, expected, update=False):
if update:<EOL><INDENT>shutil.copy(res, expected)<EOL><DEDENT>else:<EOL><INDENT>assert filecmp.cmp(res, expected, shallow=False)<EOL><DEDENT>
Run test that writing file is behaving as expected

    Parameters
    ----------
    res : str
        File written as part of the test

    expected : str
        File against which the comparison should be done

    update : bool
        If True, don't perform the test and instead simply
        overwrite the existing expected file with ``res``

    Raises
    ------
    AssertionError
        If ``update`` is ``False`` and ``res`` and ``expected``
        are not identical.