def METHOD_NAME(
        self, tmpdir, monkeypatch, environment,
        session_args):
    from argparse import Namespace
    from omero.util import get_user_dir
    from omero_ext.path import path
    for var in list(environment.keys()):
        if environment[var]:
            monkeypatch.setenv(var, "%s%s%s" % (tmpdir, os.path.sep, environment.get(var)))
        else:
            monkeypatch.delenv(var, raising=False)
    # args.session_dir sets the sessions dir
    args = Namespace()
    if session_args:
        setattr(args, session_args, old_div(tmpdir, session_args))
    if environment.get('OMERO_SESSION_DIR') or session_args:
        store = pytest.deprecated_call(self.cli.controls['sessions'].store, args)
    else:
        store = self.cli.controls['sessions'].store(args)
    # By order of precedence
    if environment.get('OMERO_SESSIONDIR'):
        sdir = old_div(path(tmpdir), environment.get('OMERO_SESSIONDIR'))
    elif environment.get('OMERO_SESSION_DIR'):
        sdir = (path(tmpdir) / environment.get('OMERO_SESSION_DIR') /
                'omero' / 'sessions')
    elif session_args:
        sdir = path(getattr(args, session_args)) / 'omero' / 'sessions'
    elif environment.get('OMERO_USERDIR'):
        sdir = path(tmpdir) / environment.get('OMERO_USERDIR') / 'sessions'
    else:
        sdir = path(get_user_dir()) / 'omero' / 'sessions'
    assert store.dir == str(sdir)