diff --git a/plumbum/commands/modifiers.py b/plumbum/commands/modifiers.py index 98b3749f..af59071a 100644 --- a/plumbum/commands/modifiers.py +++ b/plumbum/commands/modifiers.py @@ -226,6 +226,7 @@ def __rand__(self, cmd): buf.append(data) + p.wait() # To get return code in p stdout = "".join([x.decode("utf-8") for x in outbuf]) stderr = "".join([x.decode("utf-8") for x in errbuf]) return p.returncode, stdout, stderr diff --git a/tests/test_local.py b/tests/test_local.py index 889624ab..3b5eb514 100644 --- a/tests/test_local.py +++ b/tests/test_local.py @@ -607,7 +607,7 @@ def test_iter_lines_line_timeout(self): @skip_on_windows def test_modifiers(self): - from plumbum.cmd import grep, ls + from plumbum.cmd import cat, grep, ls f = (ls["-a"] | grep["\\.py"]) & BG f.wait() @@ -615,11 +615,17 @@ def test_modifiers(self): command = ls["-a"] | grep["local"] command_false = ls["-a"] | grep["not_a_file_here"] + command_false_2 = command_false | cat command & FG assert command & TF assert not (command_false & TF) + assert not (command_false_2 & TF) assert command & RETCODE == 0 assert command_false & RETCODE == 1 + assert command_false_2 & RETCODE == 1 + assert (command & TEE)[0] == 0 + assert (command_false & TEE(retcode=None))[0] == 1 + assert (command_false_2 & TEE(retcode=None))[0] == 1 @skip_on_windows def test_tee_modifier(self, capfd):