def test_multiprocess_singletask(self): source = MemorySource(list(range(4))) sink = MemorySink() Pipe.join(source, [Pipe_Tests.ProcessNameFilter()], sink).run(2, 1) self.assertEqual(len(set(sink.items)), 4)
def test_single_process_multitask(self): source = MemorySource(list(range(10))) sink = MemorySink() Pipe.join(source, [Pipe_Tests.ProcessNameFilter()], sink).run() self.assertEqual(sink.items, ['MainProcess'] * 10)
def test_logging(self): actual_logs = [] ExecutionContext.Logger = UniversalLogger( lambda msg, end: actual_logs.append((msg, end))) source = MemorySource(list(range(4))) sink = MemorySink() Pipe.join(source, [Pipe_Tests.ProcessNameFilter()], sink).run(2, 1) self.assertEqual(len(actual_logs), 4) self.assertEqual(sink.items, [l[0][20:] for l in actual_logs])
def __init__(self, transaction_log: Optional[str], restored: Result) -> None: self._sink = Pipe.join([JsonEncode()], DiskSink(transaction_log)) if transaction_log else MemorySink() self._sink = Pipe.join([TransactionIsNew(restored)], self._sink)
def test_exception_singleprocess(self): source = MemorySource(list(range(4))) sink = MemorySink() with self.assertRaises(Exception): Pipe.join(source, [Pipe_Tests.ExceptionFilter()], sink).run()