def test_separators_are_printed(self): with StringIO() as stream: sink = rprint(sep=', ', file=stream, flush=True) sink.send(12) sink.send(24) sink.send(36) result = stream.getvalue() self.assertEqual(result, "12, 24, 36") sink.close()
def test_end_terminator_is_printed(self): with StringIO() as stream: sink = rprint(end='END', file=stream, flush=True) sink.send(7) sink.send(14) sink.send(21) sink.close() result = stream.getvalue() self.assertEqual(result, "7\n14\n21END")
def test_sent_items_are_printed(self): with StringIO() as stream: sink = rprint(file=stream, flush=True) sink.send(10) sink.send(20) sink.send(30) result = stream.getvalue() self.assertEqual(result, "10\n20\n30") sink.close()
def test_closed_sink_raises_stop_iteration(self): with StringIO() as stream: sink = rprint() sink.close() with self.assertRaises(StopIteration): sink.send("StopIteration should be raised")