예제 #1
0
def test_import_bus_module_contains_bus_but_wrong_type(make_test_bus_module):
    bus_module_name = make_test_bus_module(code="bus = 123")
    with pytest.raises(FailedToImportBusModule) as e:
        import_bus_module(bus_module_name)

    assert "invalid value" in str(e).lower()
    assert "int" in str(e.value).lower()
예제 #2
0
def test_import_bus_module_does_not_exist():
    bus_module_name = "does_not_exist"
    with pytest.raises(FailedToImportBusModule) as e:
        import_bus_module(bus_module_name)

    assert "failed to import" in str(e.value).lower()
예제 #3
0
def test_import_bus_module_does_not_contain_bus(make_test_bus_module):
    bus_module_name = make_test_bus_module(code="")
    with pytest.raises(FailedToImportBusModule) as e:
        import_bus_module(bus_module_name)

    assert "attribute" in str(e.value).lower()
예제 #4
0
def test_import_bus_module_ok(make_test_bus_module):
    bus_module_name = make_test_bus_module()
    bus_module = import_bus_module(bus_module_name)

    assert inspect.ismodule(bus_module)
    assert isinstance(bus_module.bus, BusPath)