comparison test/test_run.py @ 193:98de92b816d4

Add logfile argument to treepkg.run.call to log the output of the subprocess. Add a corresponding test case.
author Bernhard Herzog <bh@intevation.de>
date Thu, 31 Jul 2008 10:00:25 +0000
parents c7ac67366492
children e3ab8aca2b08
comparison
equal deleted inserted replaced
192:eaadf5350a1a 193:98de92b816d4
8 """Tests for treepkg.run""" 8 """Tests for treepkg.run"""
9 9
10 import sys 10 import sys
11 import os 11 import os
12 import unittest 12 import unittest
13
14 from filesupport import FileTestMixin
13 15
14 from treepkg.run import call, capture_output, SubprocessError 16 from treepkg.run import call, capture_output, SubprocessError
15 17
16 18
17 19
60 try: 62 try:
61 call(subprocess_cmd, inputdata=data) 63 call(subprocess_cmd, inputdata=data)
62 except SubprocessError, exc: 64 except SubprocessError, exc:
63 self.assertEquals(exc.returncode, 1) 65 self.assertEquals(exc.returncode, 1)
64 66
67
68 class TestRunWithLogging(unittest.TestCase, FileTestMixin):
69
70 def test_run_with_logfile(self):
71 logfilename = self.temp_file_name("logfile")
72 call([sys.executable, "-c", "print \"I'm a lumber jack and I'm OK\""],
73 logfile=logfilename)
74 self.checkFileContents(logfilename, "I'm a lumber jack and I'm OK\n")
75
76
65 class TestCaptureOutput(unittest.TestCase): 77 class TestCaptureOutput(unittest.TestCase):
66 78
67 def test_capture_output_stdout(self): 79 def test_capture_output_stdout(self):
68 text = "explicit is better than implicit" 80 text = "explicit is better than implicit"
69 self.assertEquals(capture_output([sys.executable, "-c", 81 self.assertEquals(capture_output([sys.executable, "-c",
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)