PageRenderTime 47ms CodeModel.GetById 40ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/tests/core/test_event_serialization.py

https://bitbucket.org/prologic/circuits/
Python | 43 lines | 27 code | 11 blank | 5 comment | 1 complexity | b2138eaa88e592be8564465b92ef9f71 MD5 | raw file
 1# Module:   test_event_serialization
 2# Date:     13th February 2010
 3# Author:   James Mills, prologic at shortcircuit dot net dot au
 4
 5"""Event Serialization Tests"""
 6
 7from pickle import dumps, loads
 8
 9from circuits import Event, Component
10
11class Test(Event):
12    """Test Event"""
13
14    success = ("test_successful",)
15
16class App(Component):
17
18    def test(self):
19        return "Hello World!"
20
21def test():
22    app = App()
23    while app: app.flush()
24
25    e = Test()
26    app.fire(e)
27    app.flush()
28
29    s = dumps(e, -1)
30    x = loads(s)
31
32    assert e == x
33    assert hasattr(x, "args")
34    assert hasattr(x, "kwargs")
35    assert hasattr(x, "channel")
36    assert hasattr(x, "target")
37    assert hasattr(x, "success")
38    assert hasattr(x, "failure")
39    assert hasattr(x, "filter")
40    assert hasattr(x, "start")
41    assert hasattr(x, "end")
42    assert hasattr(x, "value")
43    assert hasattr(x, "source")