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 unittest 22 23 # TODO this works! awesome, start doing this more often in test packages. Also 24 # do a from . in all other places where applicable. In all other cases, use 25 # absolute paths 26 from pytilities.event import dispatcher, dispatcher_switch, Dispatcher 27 from pytilities import AttributeCollectionBase 28 from .helpers import Listener45 4933 AttributeCollectionBase.__init__(self) 34 self.inited = True 35 self.arg = arg 36 37 # just checking wheter this exists, I don't care about the event 38 self.__dispatcher.has_event("a")39 425469 7556 self.assert_(self.d.inited) 57 self.assertEquals(self.d.arg, 2) 58 self.assert_(self.d.has_event("a")) 59 self.assert_(self.d.has_event("b")) 60 61 self.d.add_handler("a", self.l.handle_noarg) 62 self.d.add_handler("b", self.l.handle_1arg) 63 self.d.dispatch_a() 64 65 self.assertEquals(self.l.read(), "noarg") 66 67 self.d.dispatch_b() 68 self.assertEquals(self.l.read(), "1arg: 5")99 10480 AttributeCollectionBase.__init__(self) 81 82 self.inited = True 83 self.arg = arg 84 85 # just checking wheter this exists, I don't care about the event 86 self.__dispatcher_switch.has_event("a") 87 88 d = Dispatcher() 89 d.register_events("a", "b") 90 self.__dispatcher_switch.append_dispatchers(d) 91 92 self.__dispatcher = d9395 self.__dispatcher.dispatch("a")9698 self.__dispatcher.dispatch("b", 5)110123 129112 self.assert_(self.d.inited) 113 self.assertEquals(self.d.arg, 2) 114 115 self.d.add_handler("a", self.l.handle_noarg) 116 self.d.add_handler("b", self.l.handle_1arg) 117 self.d.dispatch_a() 118 119 self.assertEquals(self.l.read(), "noarg") 120 121 self.d.dispatch_b() 122 self.assertEquals(self.l.read(), "1arg: 5")
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0 on Thu Jul 22 13:11:43 2010 | http://epydoc.sourceforge.net |