PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/core/test_value_serialization.py

https://bitbucket.org/prologic/circuits/
Python | 41 lines | 24 code | 12 blank | 5 comment | 2 complexity | 7f0b444c667081cbc9bdaf1a53398831 MD5 | raw file
 1# Module:   test_value_serialization
 2# Date:     25th April 2010
 3# Author:   James Mills, prologic at shortcircuit dot net dot au
 4
 5"""Value 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    v = app.fire(Test())
26    while app: app.flush()
27
28    s = dumps(v, -1)
29    x = loads(s)
30
31    assert hasattr(x, "event")
32    assert hasattr(x, "onSet")
33    assert hasattr(x, "result")
34    assert hasattr(x, "errors")
35    assert hasattr(x, "_value")
36
37    assert x.event == v.event
38    assert x.onSet == v.onSet
39    assert x.result == v.result
40    assert x.errors == v.errors
41    assert x._value == v._value