'Test plugin semantics'

def test_plugins(self):

    class Plugin(object, ):
        def __init__(self):
            self.running = Event()
            self.event = Event()
            self.port = None
        def start(self, loop):
            self.running.set()
            self.port = loop.bound_address[1]
            self.event.wait()
            self.running.clear()
        def stop(self):
            self.event.set()
    plugin = Plugin()
    with TestServer((lambda data: u'xxx'), plugins=(plugin,)) as server:
        self.assertTrue(plugin.running.wait(0.2))
        self.ae(plugin.port, server.address[1])
    self.assertTrue(plugin.event.wait(5))
    self.assertFalse(plugin.running.is_set())
