PageRenderTime 22ms CodeModel.GetById 14ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/core/test_inheritence.py

https://bitbucket.org/prologic/circuits/
Python | 53 lines | 30 code | 21 blank | 2 comment | 0 complexity | d56aa024a91ed6a319d5917043859a64 MD5 | raw file
 1#!/usr/bin/env python
 2
 3import pytest
 4
 5from circuits import handler, Event, Component
 6
 7
 8class test(Event):
 9    """test Event"""
10
11
12class Base(Component):
13
14    def test(self):
15        return "Hello World!"
16
17
18class App1(Base):
19
20    @handler("test", priority=-1)
21    def test(self):
22        return "Foobar"
23
24
25class App2(Base):
26
27    @handler("test", override=True)
28    def test(self):
29        return "Foobar"
30
31
32def test_inheritence():
33    app = App1()
34    app.start()
35
36    x = app.fire(test())
37    assert pytest.wait_for(x, "result")
38    v = x.value
39    assert v == ["Hello World!", "Foobar"]
40
41    app.stop()
42
43
44def test_override():
45    app = App2()
46    app.start()
47
48    x = app.fire(test())
49    assert pytest.wait_for(x, "result")
50    v = x.value
51    assert v == "Foobar"
52
53    app.stop()