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":
|
if c == b"\n":
|
||||||
yield flush()
|
yield flush()
|
||||||
c_last = c
|
c_last = c
|
||||||
|
if buf:
|
||||||
|
yield flush()
|
||||||
finally:
|
finally:
|
||||||
ret = proc.wait()
|
ret = proc.wait()
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
|
|
|
@ -27,6 +27,14 @@ def test_capture_cmd_capture_success():
|
||||||
assert line == "test\n"
|
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():
|
def test_capture_cmd_capture_fail():
|
||||||
with pytest.raises(subprocess.CalledProcessError):
|
with pytest.raises(subprocess.CalledProcessError):
|
||||||
for line in utils.execute_cmd(
|
for line in utils.execute_cmd(
|
||||||
|
|
Ładowanie…
Reference in New Issue