Beispiel #1
0
	def test_signal_lambda(self):
		global SIGNAL_RECIEVED
		global OBJECT_RECIEVED

		s = Signal()
		l = Listener(lambda s, o: self.assign(s, o))

		s.append(l)
		s(10)
		self.assertEqual(SIGNAL_RECIEVED, s)
		self.assertEqual(OBJECT_RECIEVED, 10)

		reset_recieved()
Beispiel #2
0
	def test_signal_remove_while_dispatch(self):
		signal = Signal()
		dummy = Dummy()
		listenerA = RemoveWhileDispatchListenerMock()
		listenerB = ListenerMock()

		signal.append(listenerA)
		signal.append(listenerB)

		self.assertEqual(len(signal), 2)

		signal(dummy)

		self.assertEqual(listenerA.count, 1)
		self.assertEqual(listenerB.count, 1)

		self.assertEqual(len(signal), 1)
Beispiel #3
0
	def test_signal_class(self):
		global SIGNAL_RECIEVED
		global OBJECT_RECIEVED
	
		s = Signal()
		l = TestListener()
		s.append(l)
		s(10)
		self.assertEqual(SIGNAL_RECIEVED, s)
		self.assertEqual(OBJECT_RECIEVED, 10)
	
		reset_recieved()
		s.remove(l)
		s(10)
		self.assertEqual(SIGNAL_RECIEVED, None)
		self.assertEqual(OBJECT_RECIEVED, None)

		reset_recieved()