コード例 #1
0
ファイル: test_handlers.py プロジェクト: xyzonline/flexx
def test_connecting():
    
    # We've done all the normal connections. We test mosly fails here
    
    h = event.HasEvents()
    
    with raises(RuntimeError):  # connect() needs args
        @event.connect
        def foo(*events):
            pass
    with raises(RuntimeError):
        @h.connect
        def foo(*events):
            pass
    
    with raises(ValueError):  # connect() needs strings
        @event.connect(3)
        def foo(*events):
            pass
    with raises(ValueError):
        @h.connect(3)
        def foo(*events):
            pass
    
    with raises(TypeError):  # connect() needs callable
        event.connect('x')(3)
    with raises(TypeError):  # connect() needs callable
        h.connect('x')(3)
    
    with raises(RuntimeError):  # cannot connect
        h.xx = None
        @h.connect('xx.foobar')
        def foo(*events):
            pass
コード例 #2
0
ファイル: test_handlers.py プロジェクト: Python-PyBD/flexx
def test_connecting():
    
    # We've done all the normal connections. We test mosly fails here
    
    h = event.HasEvents()
    
    with raises(RuntimeError):  # connect() needs args
        @event.connect
        def foo(*events):
            pass
    with raises(RuntimeError):
        @h.connect
        def foo(*events):
            pass
    
    with raises(ValueError):  # connect() needs strings
        @event.connect(3)
        def foo(*events):
            pass
    with raises(ValueError):
        @h.connect(3)
        def foo(*events):
            pass
    
    with raises(TypeError):  # connect() needs callable
        event.connect('x')(3)
    with raises(TypeError):  # connect() needs callable
        h.connect('x')(3)
    
    with raises(RuntimeError):  # cannot connect
        h.xx = None
        @h.connect('xx.foobar')
        def foo(*events):
            pass
コード例 #3
0
ファイル: test_handlers.py プロジェクト: xyzonline/flexx
 class Foo(event.HasEvents):
     
     def _handle1(self, *events):
         events1.extend(events)
     handle1 = event.connect(_handle1, 'x1')
     
     def _handle2(self, *events):
         events2.extend(events)
     handle2 = event.connect(_handle2, 'x1', 'x2')