Fixes #1490
progress_stream would print a lot of new lines on "docker-compose pull" if there's no tty. Signed-off-by: Yves Peter <ypdraw@gmail.com>
This commit is contained in:
parent
2063b39868
commit
b8b4c84573
2 changed files with 45 additions and 9 deletions
|
|
@ -34,3 +34,34 @@ class ProgressStreamTestCase(unittest.TestCase):
|
|||
]
|
||||
events = progress_stream.stream_output(output, StringIO())
|
||||
self.assertEqual(len(events), 1)
|
||||
|
||||
def test_stream_output_progress_event_tty(self):
|
||||
events = [
|
||||
b'{"status": "Already exists", "progressDetail": {}, "id": "8d05e3af52b0"}'
|
||||
]
|
||||
|
||||
class TTYStringIO(StringIO):
|
||||
def isatty(self):
|
||||
return True
|
||||
|
||||
output = TTYStringIO()
|
||||
events = progress_stream.stream_output(events, output)
|
||||
self.assertTrue(len(output.getvalue()) > 0)
|
||||
|
||||
def test_stream_output_progress_event_no_tty(self):
|
||||
events = [
|
||||
b'{"status": "Already exists", "progressDetail": {}, "id": "8d05e3af52b0"}'
|
||||
]
|
||||
output = StringIO()
|
||||
|
||||
events = progress_stream.stream_output(events, output)
|
||||
self.assertEqual(len(output.getvalue()), 0)
|
||||
|
||||
def test_stream_output_no_progress_event_no_tty(self):
|
||||
events = [
|
||||
b'{"status": "Pulling from library/xy", "id": "latest"}'
|
||||
]
|
||||
output = StringIO()
|
||||
|
||||
events = progress_stream.stream_output(events, output)
|
||||
self.assertTrue(len(output.getvalue()) > 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue