From 7dda975c059342afe48cb50e20c5ae7e3d3bf5d6 Mon Sep 17 00:00:00 2001 From: Harry Date: Tue, 4 Nov 2014 09:28:59 +0000 Subject: [PATCH] handle case where stdout is the empty string --- procs.py | 3 +-- tests/test_procs.py | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/procs.py b/procs.py index 867878b..f5a0fd2 100644 --- a/procs.py +++ b/procs.py @@ -30,9 +30,8 @@ class Process(object): @property def stdout(self): - if self._stdout: + if self._stdout is not None: return self._stdout - return 'stdout' @property def stderr(self): diff --git a/tests/test_procs.py b/tests/test_procs.py index 0d055b4..5ebe897 100644 --- a/tests/test_procs.py +++ b/tests/test_procs.py @@ -15,6 +15,12 @@ def test_single_proc(): assert ls.stdout == u'file1\nfile2\nfile3\n' +def test_empty_output(): + cat = Process('cat /dev/null') + cat.run() + assert cat.stdout == u'' + + def test_returncode(): assert not os.path.exists('/bin/nosuchcommand')