Permalink
Browse files

Must open /dev/null for writing.

Very curious that this didn't cause a problem with stdout,
just stderr. Thank you to Lenna and Saket for spotting this
http://lists.open-bio.org/pipermail/biopython-dev/2013-March/010488.html

Finding and fixing this unreported bug was a nice bonus from
writing test_Application.py :)
  • Loading branch information...
1 parent 3f5d4c4 commit bba2acbf3d690ad7b99e94ac8ead6763b1d05ab8 @peterjc peterjc committed Mar 28, 2013
Showing with 12 additions and 20 deletions.
  1. +2 −2 Bio/Application/__init__.py
  2. +10 −18 Tests/test_Application.py
@@ -415,11 +415,11 @@ def __call__(self, stdin=None, stdout=True, stderr=True,
if stdout:
stdout_arg = subprocess.PIPE
else:
- stdout_arg = open(os.devnull)
+ stdout_arg = open(os.devnull, "w")
if stderr:
stderr_arg = subprocess.PIPE
else:
- stderr_arg = open(os.devnull)
+ stderr_arg = open(os.devnull, "w")
#We may not need to supply any piped input, but we setup the
#standard input pipe anyway as a work around for a python
#bug if this is called from a Windows GUI program. For
View
@@ -38,25 +38,17 @@ def test_echo_capture_stdout(self):
self.assertEqual(stderr, None)
self.assertEqual(stdout, "Hello World\n")
- #Same failure on Linux, Mac OS X:
- # ApplicationError: Command 'echo Hello World' returned non-zero exit status 1,
- # '/bin/sh: line 0: echo: write error: Bad file descriptor'
- #And on Windows XP (with cygwin):
- # ApplicationError: Command 'echo Hello World' returned non-zero exit status 1,
- # 'echo: write error: Bad file descriptor'
- #def test_echo_capture_stderr(self):
- # cline = EchoApp(text="Hello World")
- # stdout, stderr = cline(stdout=False, stderr=True)
- # self.assertEqual(stderr, "")
- # self.assertEqual(stdout, None)
+ def test_echo_capture_stderr(self):
+ cline = EchoApp(text="Hello World")
+ stdout, stderr = cline(stdout=False, stderr=True)
+ self.assertEqual(stderr, "")
+ self.assertEqual(stdout, None)
- #Same failure on Linux, Mac OS X, and Windows XP (with cygwin):
- # ApplicationError: Command 'echo Hello World' returned non-zero exit status 1
- #def test_echo_capture_neither(self):
- # cline = EchoApp(text="Hello World")
- # stdout, stderr = cline(stdout=False, stderr=False)
- # self.assertEqual(stderr, None)
- # self.assertEqual(stdout, None)
+ def test_echo_capture_neither(self):
+ cline = EchoApp(text="Hello World")
+ stdout, stderr = cline(stdout=False, stderr=False)
+ self.assertEqual(stderr, None)
+ self.assertEqual(stdout, None)
if __name__ == "__main__":

0 comments on commit bba2acb

Please sign in to comment.