Example #1
0
def test_addListener():
    print("Add Listener to Module without Sender:", end=" ")
    try:
        with contextlib.redirect_stdout(None):
            m = Module("test2")
            m.addListener("name")
            assert m.getValue("name") == None
            assert m["name"][0] == None
            m.stopModule()
        print("FAILED")
    except:
        print("SUCCESSED")
        assert True
Example #2
0
def test_addListener2():
    print("Add Listener to Module with Sender:", end=" ")
    try:
        with contextlib.redirect_stdout(None):
            m = Module("test3")
            m.addSender("name", value=10)
            m2 = Module("test3b")
            m2.addListener("name")
            assert m2.getValue("name") == 10
            assert m2["name"][0] == 10
            m.stopModule()
            m2.stopModule()
        print("SUCCESSED")
    except:
        print("FAILED")
        assert False
Example #3
0
def test_availability2():
    print("Testing availability bis:", end=" ")
    try:
        with contextlib.redirect_stdout(None):
            m = Module("test14a")
            m2 = Module("test14b")
            m.addSender("name", value=10)
            m2.addListener("name")
            assert m.getLSAvailability(sender=True) == ([True], [])
            assert m2.getLSAvailability(listener=True) == ([], [True])
            m.stopModule()
            m2.stopModule()
        print("SUCCESSED")
    except:
        print("FAILED")
        assert False
Example #4
0
def test_():
    print("Stopping Modules:", end=" ")
    try:
        with contextlib.redirect_stdout(None):
            m = Module("test12a")
            m2 = Module("test12b")
            m.addSender("name", value=10)
            m2.addListener("name")
            m.stopModule("name")
            m.stopModule()
            m2.stopModule()
        assert True
        print("SUCCESSED")
    except:
        print("FAILED")
        assert False
Example #5
0
def test_setValue3():
    print("Listener edit value:", end=" ")
    try:
        with contextlib.redirect_stdout(None):
            m = Module("test9a")
            m.addSender("name", value=10)
            m2 = Module("test9b")
            m2.addListener("name")
            m2.setValue("name", 20)
            assert m.getValue("name") == 20
            assert m2["name"][0] == 20
            m.stopModule()
            m2.stopModule()
        print("SUCCESSED")
    except:
        print("FAILED")
        assert False
Example #6
0
def test_delListener():
    print("Removing Listener:", end=" ")
    try:
        with contextlib.redirect_stdout(None):
            m = Module("test11a")
            m2 = Module("test11b")
            m.addSender("name", value=10)
            m2.addListener("name")
            _, _l = m2.getLSName()
            assert len(_l) == 1
            m2.delListener("name")
            _, _l = m2.getLSName()
            assert len(_l) == 0
            m.stopModule()
            m2.stopModule()
        print("SUCCESSED")
    except:
        print("FAILED")
        assert False