From 5e1e0daa5c59525cab18cff9605422f46cd14d37 Mon Sep 17 00:00:00 2001 From: WillyPillow Date: Mon, 7 Sep 2020 01:18:59 +0800 Subject: [PATCH] Make TestProcess.communicate return str instead of IO object --- qubesadmin/tests/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qubesadmin/tests/__init__.py b/qubesadmin/tests/__init__.py index 787c3d9..a0fa1e6 100644 --- a/qubesadmin/tests/__init__.py +++ b/qubesadmin/tests/__init__.py @@ -60,11 +60,13 @@ class TestProcess(object): self.stdin_close = self.stdin.close self.stdin.close = self.store_input self.stdin.flush = self.store_input - if stdout == subprocess.PIPE: + if stdout == subprocess.PIPE or stdout == subprocess.DEVNULL \ + or stdout is None: self.stdout = io.BytesIO() else: self.stdout = stdout - if stderr == subprocess.PIPE: + if stderr == subprocess.PIPE or stderr == subprocess.DEVNULL \ + or stderr is None: self.stderr = io.BytesIO() else: self.stderr = stderr @@ -82,7 +84,7 @@ class TestProcess(object): self.stdin.write(input) self.stdin.close() self.stdin_close() - return self.stdout, self.stderr + return self.stdout.read(), self.stderr.read() def wait(self): self.stdin_close()