def METHOD_NAME(dir, expected, glob=None):
    """
    assert that (only) ``expected`` files are in ``dir``.
    ``filter`` can be a globbing patter, other files are ignored if it is set.
    """
    if glob is not None:
        files = globfunc(os.path.join(dir, glob))
        files = [os.path.basename(f) for f in files]
    else:
        files = os.listdir(dir)
    files.sort()
    assert sorted(expected) == files