kopia lustrzana https://github.com/jupyterhub/repo2docker
Merge pull request #850 from manics/execute_cmd-flush
[MRG] utils.execute_cmd flush buffer if no EOLpull/855/head
commit
d8ccf36b11
|
@ -50,6 +50,8 @@ def execute_cmd(cmd, capture=False, **kwargs):
|
|||
if c == b"\n":
|
||||
yield flush()
|
||||
c_last = c
|
||||
if buf:
|
||||
yield flush()
|
||||
finally:
|
||||
ret = proc.wait()
|
||||
if ret != 0:
|
||||
|
|
|
@ -27,6 +27,14 @@ def test_capture_cmd_capture_success():
|
|||
assert line == "test\n"
|
||||
|
||||
|
||||
def test_capture_cmd_noeol_capture_success():
|
||||
# This should succeed
|
||||
lines = list(
|
||||
utils.execute_cmd(["/bin/bash", "-c", "echo -en 'test\ntest'"], capture=True)
|
||||
)
|
||||
assert lines == ["test\n", "test"]
|
||||
|
||||
|
||||
def test_capture_cmd_capture_fail():
|
||||
with pytest.raises(subprocess.CalledProcessError):
|
||||
for line in utils.execute_cmd(
|
||||
|
|
Ładowanie…
Reference in New Issue