Esempio n. 1
0
def test_adapter_registry_import_error():
    error_msg = re.escape(
        "To run 'MODELNAME' you need to install additional dependencies. Please "
        "install them using `pip install openscm[model-MODELNAME]`.")
    with patch.dict(sys.modules, {"openscm.adapters.modelname": None}):
        with pytest.raises(AdapterNeedsModuleError, match=error_msg):
            load_adapter("MODELNAME")
Esempio n. 2
0
def test_adapter_registry_unknown_model():
    # make sure we didn't break _loaded_adapters in previous test
    with pytest.raises(KeyError, match="Unknown model 'stub'"):
        load_adapter("stub")

    with pytest.raises(KeyError, match="Unknown model 'unknown'"):
        load_adapter("unknown")
Esempio n. 3
0
def test_load_model():
    with patch.dict(sys.modules, {"openscm.adapters.modelname": MagicMock()}):
        load_adapter("MODELNAME")
Esempio n. 4
0
def test_adapter_registry():
    assert load_adapter("stub") == 1