[PATCH] get rid of DeprecationWarnings when running tests
Mike Bonnet <[email protected]> Thu, 17 Sep 2009 11:37:05 -0400
| Newsgroups | gmane.comp.python.cheetah |
|---|---|
| Message-ID | <[email protected]> |
Implemented the popen2.Popen4 interface using the subprocess.Popen backend, to avoid DeprecationWarnings when running the tests on python >= 2.6.
---
cheetah/Tests/CheetahWrapper.py | 15 +++++++++++++--
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()
--
1.6.2.5
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf