summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bonnet <mikeb@redhat.com>2009-09-15 17:55:31 -0400
committerR. Tyler Ballance <tyler@slide.com>2009-09-17 11:20:39 -0700
commitd6cc8d39f8248182590cdb1bcf56d0e477dbd6b9 (patch)
tree914b991ed49767a413a0b1d278fdb24522d58143
parent9050b8bf0fa67e098aae6f6f9f675530ffffd364 (diff)
downloadpython-cheetah-d6cc8d39f8248182590cdb1bcf56d0e477dbd6b9.tar.gz
implement the popen2.Popen4 interface using the subprocess.Popen backend, to avoid DeprecationWarnings when running the tests on python >= 2.6
Finally got tired of 'em. :)
-rw-r--r--cheetah/Tests/CheetahWrapper.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/cheetah/Tests/CheetahWrapper.py b/cheetah/Tests/CheetahWrapper.py
index ca7b0ae..e152e68 100644
--- a/cheetah/Tests/CheetahWrapper.py
+++ b/cheetah/Tests/CheetahWrapper.py
@@ -12,7 +12,6 @@ Besides unittest usage, recognizes the following command-line options:
Show the output of each subcommand. (Normally suppressed.)
'''
import os
-import popen2
import re # Used by listTests.
import shutil
import sys
@@ -22,6 +21,18 @@ import unittest
from optparse import OptionParser
from Cheetah.CheetahWrapper import CheetahWrapper # Used by NoBackup.
+try:
+ from subprocess import Popen, PIPE, STDOUT
+ class Popen4(Popen):
+ def __init__(self, cmd, bufsize=-1):
+ super(Popen4, self).__init__(cmd, bufsize=bufsize,
+ shell=True, close_fds=True,
+ stdin=PIPE, stdout=PIPE, stderr=STDOUT)
+ self.tochild = self.stdin
+ self.fromchild = self.stdout
+ self.childerr = self.stderr
+except ImportError:
+ from popen2 import Popen4
DELETE = True # True to clean up after ourselves, False for debugging.
OUTPUT = False # Normally False, True for debugging.
@@ -152,7 +163,7 @@ Found %(result)r"""
return rc, output
def assertPosixSubprocess(self, cmd):
- process = popen2.Popen4(cmd)
+ process = Popen4(cmd)
process.tochild.close()
output = process.fromchild.read()
status = process.wait()