def test_sigpipe(self): r, w = os.pipe() task = prepare_task(self.Infinite, outstream=os.fdopen(w, 'w')) raised = Queue(maxsize=1) def execute(): try: task.execute([]) except IOError as e: raised.put(e) execution = threading.Thread(target=execute, name='ConsoleTaskTest_sigpipe') execution.setDaemon(True) execution.start() try: data = os.read(r, 5) self.assertEqual('jake\n', data) os.close(r) finally: task.stop() execution.join() with pytest.raises(Empty): e = raised.get_nowait() # Instead of taking the generic pytest.raises message, provide a more detailed failure # message that shows exactly what untrapped error was on the queue. self.fail('task raised %s' % e)
def execute_task(self, config=sample_ini_test_1): with closing(StringIO()) as output: task = prepare_task(BuildBuildDictionary, config=config) task.execute(()) return output.getvalue()