def test_with_log_stream(self, mock_container): mock_container.log_stream = iter([b"hello\nworld"]) log_args = {'follow': True} generator = build_log_generator(mock_container, log_args) assert next(generator) == "hello\n" assert next(generator) == "world"
def test_no_log_stream(self, mock_container): mock_container.log_stream = None mock_container.logs.return_value = iter([b"hello\nworld"]) log_args = {"follow": True} generator = build_log_generator(mock_container, log_args) assert next(generator) == "hello\n" assert next(generator) == "world" mock_container.logs.assert_called_once_with(stdout=True, stderr=True, stream=True, **log_args)
def test_no_log_stream(self, mock_container): mock_container.log_stream = None mock_container.logs.return_value = iter([b"hello\nworld"]) log_args = {'follow': True} generator = build_log_generator(mock_container, log_args) assert next(generator) == "hello\n" assert next(generator) == "world" mock_container.logs.assert_called_once_with(stdout=True, stderr=True, stream=True, **log_args)
def test_unicode(self, output_stream): glyph = u'\u2022\n' mock_container.log_stream = iter([glyph.encode('utf-8')]) generator = build_log_generator(mock_container, {}) assert next(generator) == glyph