def set_pyoptsparse_opt(optname, fallback=True):
    "\n    For testing, sets the pyoptsparse optimizer using the given optimizer name.\n\n    This may be modified based on the value of OPENMDAO_FORCE_PYOPTSPARSE_OPT.\n    This can be used on systems that have SNOPT installed to force them to use\n    SLSQP in order to mimic our test machines on travis and appveyor.\n\n    Parameters\n    ----------\n    optname : str\n        Name of pyoptsparse optimizer that is requested by the test.\n    fallback : bool\n        If True, fall back to SLSQP if optname can't be found.\n\n    Returns\n    -------\n    object\n        Pyoptsparse optimizer instance.\n    str\n        Pyoptsparse optimizer string.\n    "
    OPT = None
    opt = None
    OPTIMIZER = None
    force = os.environ.get('OPENMDAO_FORCE_PYOPTSPARSE_OPT')
    if force:
        optname = force
    from unittest.mock import Mock
    try:
        from pyoptsparse import OPT
        try:
            opt = OPT(optname)
            OPTIMIZER = optname
        except Exception:
            if (fallback and (optname != 'SLSQP')):
                try:
                    opt = OPT('SLSQP')
                    OPTIMIZER = 'SLSQP'
                except Exception:
                    pass
        else:
            if (fallback and isinstance(opt, Mock)):
                try:
                    opt = OPT('SLSQP')
                    OPTIMIZER = 'SLSQP'
                except Exception:
                    pass
    except Exception:
        pass
    if isinstance(opt, Mock):
        OPT = OPTIMIZER = None
    if ((not fallback) and (OPTIMIZER != optname)):
        raise unittest.SkipTest(('pyoptsparse is not providing %s' % optname))
    return (OPT, OPTIMIZER)
For testing, sets the pyoptsparse optimizer using the given optimizer name.

This may be modified based on the value of OPENMDAO_FORCE_PYOPTSPARSE_OPT.
This can be used on systems that have SNOPT installed to force them to use
SLSQP in order to mimic our test machines on travis and appveyor.

Parameters
----------
optname : str
    Name of pyoptsparse optimizer that is requested by the test.
fallback : bool
    If True, fall back to SLSQP if optname can't be found.

Returns
-------
object
    Pyoptsparse optimizer instance.
str
    Pyoptsparse optimizer string.
def set_pyoptsparse_opt(optname, fallback=True):
    "\n    For testing, sets the pyoptsparse optimizer using the given optimizer name.\n\n    This may be modified based on the value of OPENMDAO_FORCE_PYOPTSPARSE_OPT.\n    This can be used on systems that have SNOPT installed to force them to use\n    SLSQP in order to mimic our test machines on travis and appveyor.\n\n    Parameters\n    ----------\n    optname : str\n        Name of pyoptsparse optimizer that is requested by the test.\n    fallback : bool\n        If True, fall back to SLSQP if optname can't be found.\n\n    Returns\n    -------\n    object\n        Pyoptsparse optimizer instance.\n    str\n        Pyoptsparse optimizer string.\n    "
    OPT = None
    opt = None
    OPTIMIZER = None
    force = os.environ.get('OPENMDAO_FORCE_PYOPTSPARSE_OPT')
    if force:
        optname = force
    from unittest.mock import Mock
    try:
        from pyoptsparse import OPT
        try:
            opt = OPT(optname)
            OPTIMIZER = optname
        except Exception:
            if (fallback and (optname != 'SLSQP')):
                try:
                    opt = OPT('SLSQP')
                    OPTIMIZER = 'SLSQP'
                except Exception:
                    pass
        else:
            if (fallback and isinstance(opt, Mock)):
                try:
                    opt = OPT('SLSQP')
                    OPTIMIZER = 'SLSQP'
                except Exception:
                    pass
    except Exception:
        pass
    if isinstance(opt, Mock):
        OPT = OPTIMIZER = None
    if ((not fallback) and (OPTIMIZER != optname)):
        raise unittest.SkipTest(('pyoptsparse is not providing %s' % optname))
    return (OPT, OPTIMIZER)