Merge remote-tracking branch 'origin/pull/58/head' into core3-devel
This commit is contained in:
		
						commit
						c6c0a545e6
					
				| @ -33,7 +33,7 @@ import qubes.vm.adminvm | ||||
| import qubes.ext.r3compatibility | ||||
| 
 | ||||
| 
 | ||||
| class AppVM(qubes.vm.appvm.AppVM): | ||||
| class AppVM(qubes.vm.appvm.AppVM):  # pylint: disable=too-many-ancestors | ||||
|     """core2 compatibility AppVM class, with variable dir_path""" | ||||
|     dir_path = qubes.property('dir_path', | ||||
|         # pylint: disable=undefined-variable | ||||
| @ -46,7 +46,8 @@ class AppVM(qubes.vm.appvm.AppVM): | ||||
|         return False | ||||
| 
 | ||||
| class StandaloneVM(qubes.vm.standalonevm.StandaloneVM): | ||||
|     """core2 compatibility StandaloneVM class, with variable dir_path""" | ||||
|     """core2 compatibility StandaloneVM class, with variable dir_path | ||||
|     """  # pylint: disable=too-many-ancestors | ||||
|     dir_path = qubes.property('dir_path', | ||||
|         # pylint: disable=undefined-variable | ||||
|         default=(lambda self: super(StandaloneVM, self).dir_path), | ||||
|  | ||||
| @ -135,7 +135,10 @@ class Emitter(object): | ||||
|         for cls in order: | ||||
|             if not hasattr(cls, '__handlers__'): | ||||
|                 continue | ||||
|             for func in sorted(cls.__handlers__[event], | ||||
|             handlers = cls.__handlers__[event] | ||||
|             if '*' in cls.__handlers__: | ||||
|                 handlers = cls.__handlers__['*'] | handlers | ||||
|             for func in sorted(handlers, | ||||
|                     key=(lambda handler: hasattr(handler, 'ha_bound')), | ||||
|                     reverse=True): | ||||
|                 effect = func(self, event, *args, **kwargs) | ||||
|  | ||||
| @ -82,3 +82,27 @@ class TC_00_Emitter(qubes.tests.QubesTestCase): | ||||
| 
 | ||||
|         self.assertItemsEqual(effect, | ||||
|             ('testvalue1', 'testvalue2', 'testvalue3', 'testvalue4')) | ||||
| 
 | ||||
|     def test_004_catch_all(self): | ||||
|         # need something mutable | ||||
|         testevent_fired = [0] | ||||
| 
 | ||||
|         def on_all(subject, event, *args, **kwargs): | ||||
|             # pylint: disable=unused-argument | ||||
|             testevent_fired[0] += 1 | ||||
| 
 | ||||
|         def on_foo(subject, event, *args, **kwargs): | ||||
|             # pylint: disable=unused-argument | ||||
|             testevent_fired[0] += 1 | ||||
| 
 | ||||
|         emitter = qubes.events.Emitter() | ||||
|         emitter.add_handler('*', on_all) | ||||
|         emitter.add_handler('foo', on_foo) | ||||
|         emitter.events_enabled = True | ||||
|         emitter.fire_event('testevent') | ||||
|         self.assertEqual(testevent_fired[0], 1) | ||||
|         emitter.fire_event('foo') | ||||
|         # now catch-all and foo should be executed | ||||
|         self.assertEqual(testevent_fired[0], 3) | ||||
|         emitter.fire_event('bar') | ||||
|         self.assertEqual(testevent_fired[0], 4) | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Wojtek Porczyk
						Wojtek Porczyk