def __init__(self, transform=None, input_channels=None, output_channels=None): # Use the callable name if provided if transform and not self._name: self._name = transform.__name__ self.INPUT_CHANNELS = input_channels or self.INPUT_CHANNELS self.OUTPUT_CHANNELS = output_channels or self.OUTPUT_CHANNELS self._input = InputMultiplexer(self.INPUT_CHANNELS) self._output = OutputDemultiplexer(self.OUTPUT_CHANNELS) self._exec_time = 0.0 self._exec_count = 0 self._booted = False self._initialized = False self._finalized = False self.transform = transform or self.transform
def test_multiple_input(self): imux = InputMultiplexer([CH1, CH2]) # inactive on mux creation self.assertRaises(InactiveWritableError, imux[CH1].put, 'foo') self.assertRaises(InactiveWritableError, imux[CH2].put, 'foo') # activate imux[CH1].put(Begin) imux[CH1].put('foo') imux[CH1].put('foo-oo') # simple get. self.assertEqual(imux.get(), ( 'foo', CH1, )) imux[CH1].put(End) imux[CH2].put(Begin) imux[CH2].put('bar') imux[CH2].put('ba-ar') imux[CH2].put(End) self.assertEqual(imux.get(), ( 'foo-oo', CH1, )) self.assertEqual(imux.get(), ( 'bar', CH2, )) self.assertEqual(imux.get(), ( 'ba-ar', CH2, )) self.assertRaises(InactiveReadableError, imux.get)