Home | Trees | Indices | Help |
|
---|
|
1 # Copyright (C) 2010 Tim Diels <limyreth@users.sourceforge.net> 2 # 3 # This file is part of pytilities. 4 # 5 # pytilities is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # pytilities is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with pytilities. If not, see <http://www.gnu.org/licenses/>. 17 # 18 19 __docformat__ = 'reStructuredText' 20 21 import pdb 22 import unittest 23 24 # TODO this works! awesome, start doing this more often in test packages. Also 25 # do a from . in all other places where applicable. In all other cases, use 26 # absolute paths 27 from .. import dispatcher, dispatcher_switch, Dispatcher 28 from .helpers import Listener 29 from pytilities import AttributeCollectionBase46 5034 AttributeCollectionBase.__init__(self) 35 self.inited = True 36 self.arg = arg 37 38 # just checking wheter this exists, I don't care about the event 39 self.__dispatcher.has_event("a")40 435570 7657 self.assert_(self.d.inited) 58 self.assertEquals(self.d.arg, 2) 59 self.assert_(self.d.has_event("a")) 60 self.assert_(self.d.has_event("b")) 61 62 self.d.add_handler("a", self.l.handle_noarg) 63 self.d.add_handler("b", self.l.handle_1arg) 64 self.d.dispatch_a() 65 66 self.assertEquals(self.l.read(), "noarg") 67 68 self.d.dispatch_b() 69 self.assertEquals(self.l.read(), "1arg: 5")100 10581 AttributeCollectionBase.__init__(self) 82 83 self.inited = True 84 self.arg = arg 85 86 # just checking wheter this exists, I don't care about the event 87 self.__dispatcher_switch.has_event("a") 88 89 d = Dispatcher() 90 d.register_events("a", "b") 91 self.__dispatcher_switch.append_dispatchers(d) 92 93 self.__dispatcher = d9496 self.__dispatcher.dispatch("a")9799 self.__dispatcher.dispatch("b", 5)111124 130 134113 self.assert_(self.d.inited) 114 self.assertEquals(self.d.arg, 2) 115 116 self.d.add_handler("a", self.l.handle_noarg) 117 self.d.add_handler("b", self.l.handle_1arg) 118 self.d.dispatch_a() 119 120 self.assertEquals(self.l.read(), "noarg") 121 122 self.d.dispatch_b() 123 self.assertEquals(self.l.read(), "1arg: 5")
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0 on Mon Jul 19 11:49:30 2010 | http://epydoc.sourceforge.net |