mirror of https://github.com/docker/compose.git
Fix geneartors for python3.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
4312c93eae
commit
48ed68eeaa
|
@ -112,7 +112,7 @@ def build_thread(container, presenter, queue, log_args):
|
||||||
|
|
||||||
def build_thread_map(initial_containers, presenters, thread_args):
|
def build_thread_map(initial_containers, presenters, thread_args):
|
||||||
return {
|
return {
|
||||||
container.id: build_thread(container, presenters.next(), *thread_args)
|
container.id: build_thread(container, next(presenters), *thread_args)
|
||||||
for container in initial_containers
|
for container in initial_containers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ def watch_events(thread_map, event_stream, presenters, thread_args):
|
||||||
|
|
||||||
thread_map[event['id']] = build_thread(
|
thread_map[event['id']] = build_thread(
|
||||||
event['container'],
|
event['container'],
|
||||||
presenters.next(),
|
next(presenters),
|
||||||
*thread_args)
|
*thread_args)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,13 +43,13 @@ class TestLogPresenter(object):
|
||||||
|
|
||||||
def test_monochrome(self, mock_container):
|
def test_monochrome(self, mock_container):
|
||||||
presenters = build_log_presenters(['foo', 'bar'], True)
|
presenters = build_log_presenters(['foo', 'bar'], True)
|
||||||
presenter = presenters.next()
|
presenter = next(presenters)
|
||||||
actual = presenter.present(mock_container, "this line")
|
actual = presenter.present(mock_container, "this line")
|
||||||
assert actual == "web_1 | this line"
|
assert actual == "web_1 | this line"
|
||||||
|
|
||||||
def test_polychrome(self, mock_container):
|
def test_polychrome(self, mock_container):
|
||||||
presenters = build_log_presenters(['foo', 'bar'], False)
|
presenters = build_log_presenters(['foo', 'bar'], False)
|
||||||
presenter = presenters.next()
|
presenter = next(presenters)
|
||||||
actual = presenter.present(mock_container, "this line")
|
actual = presenter.present(mock_container, "this line")
|
||||||
assert '\033[' in actual
|
assert '\033[' in actual
|
||||||
|
|
||||||
|
@ -81,8 +81,8 @@ class TestBuildLogGenerator(object):
|
||||||
log_args = {'follow': True}
|
log_args = {'follow': True}
|
||||||
|
|
||||||
generator = build_log_generator(mock_container, log_args)
|
generator = build_log_generator(mock_container, log_args)
|
||||||
assert generator.next() == "hello\n"
|
assert next(generator) == "hello\n"
|
||||||
assert generator.next() == "world"
|
assert next(generator) == "world"
|
||||||
mock_container.logs.assert_called_once_with(
|
mock_container.logs.assert_called_once_with(
|
||||||
stdout=True,
|
stdout=True,
|
||||||
stderr=True,
|
stderr=True,
|
||||||
|
@ -94,15 +94,15 @@ class TestBuildLogGenerator(object):
|
||||||
log_args = {'follow': True}
|
log_args = {'follow': True}
|
||||||
|
|
||||||
generator = build_log_generator(mock_container, log_args)
|
generator = build_log_generator(mock_container, log_args)
|
||||||
assert generator.next() == "hello\n"
|
assert next(generator) == "hello\n"
|
||||||
assert generator.next() == "world"
|
assert next(generator) == "world"
|
||||||
|
|
||||||
def test_unicode(self, output_stream):
|
def test_unicode(self, output_stream):
|
||||||
glyph = u'\u2022\n'
|
glyph = u'\u2022\n'
|
||||||
mock_container.log_stream = iter([glyph.encode('utf-8')])
|
mock_container.log_stream = iter([glyph.encode('utf-8')])
|
||||||
|
|
||||||
generator = build_log_generator(mock_container, {})
|
generator = build_log_generator(mock_container, {})
|
||||||
assert generator.next() == glyph
|
assert next(generator) == glyph
|
||||||
|
|
||||||
|
|
||||||
class TestConsumeQueue(object):
|
class TestConsumeQueue(object):
|
||||||
|
@ -118,10 +118,10 @@ class TestConsumeQueue(object):
|
||||||
queue.put(item)
|
queue.put(item)
|
||||||
|
|
||||||
generator = consume_queue(queue, False)
|
generator = consume_queue(queue, False)
|
||||||
assert generator.next() == 'a'
|
assert next(generator) == 'a'
|
||||||
assert generator.next() == 'b'
|
assert next(generator) == 'b'
|
||||||
with pytest.raises(Problem):
|
with pytest.raises(Problem):
|
||||||
generator.next()
|
next(generator)
|
||||||
|
|
||||||
def test_item_is_stop_without_cascade_stop(self):
|
def test_item_is_stop_without_cascade_stop(self):
|
||||||
queue = Queue()
|
queue = Queue()
|
||||||
|
@ -129,8 +129,8 @@ class TestConsumeQueue(object):
|
||||||
queue.put(item)
|
queue.put(item)
|
||||||
|
|
||||||
generator = consume_queue(queue, False)
|
generator = consume_queue(queue, False)
|
||||||
assert generator.next() == 'a'
|
assert next(generator) == 'a'
|
||||||
assert generator.next() == 'b'
|
assert next(generator) == 'b'
|
||||||
|
|
||||||
def test_item_is_stop_with_cascade_stop(self):
|
def test_item_is_stop_with_cascade_stop(self):
|
||||||
queue = Queue()
|
queue = Queue()
|
||||||
|
@ -142,4 +142,4 @@ class TestConsumeQueue(object):
|
||||||
def test_item_is_none_when_timeout_is_hit(self):
|
def test_item_is_none_when_timeout_is_hit(self):
|
||||||
queue = Queue()
|
queue = Queue()
|
||||||
generator = consume_queue(queue, False)
|
generator = consume_queue(queue, False)
|
||||||
assert generator.next() is None
|
assert next(generator) is None
|
||||||
|
|
Loading…
Reference in New Issue