From eb0079afa437b51f9f8df5a8c96a89182b88a075 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Sun, 30 Jan 2011 18:26:01 -0500 Subject: make function on 2.4 and 2.5 --- template_tests.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'template_tests.py') diff --git a/template_tests.py b/template_tests.py index a6fba2639..8e70e7eb3 100644 --- a/template_tests.py +++ b/template_tests.py @@ -1,3 +1,4 @@ +import sys import httplib import os import pkg_resources @@ -5,6 +6,15 @@ import shutil import subprocess import tempfile import time +import signal + +if not hasattr(subprocess, 'check_call'): + # 2.4 + def check_call(*arg, **kw): + returncode = subprocess.call(*arg, **kw) + if returncode: + raise ValueError(returncode) + subprocess.check_call = check_call class TemplateTest(object): def make_venv(self, directory): @@ -47,14 +57,23 @@ class TemplateTest(object): resp = conn.getresponse() assert(resp.status == 200) finally: - proc.terminate() + if hasattr(proc, 'terminate'): + # 2.6+ + proc.terminate() + else: + # 2.5 + os.kill(proc.pid, signal.SIGTERM) finally: shutil.rmtree(self.directory) os.chdir(self.old_cwd) +templates = ['pyramid_starter', 'pyramid_alchemy', 'pyramid_routesalchemy',] + +if sys.version_info >= (2, 5): + templates.append('pyramid_zodb') + if __name__ == '__main__': - for name in ('pyramid_starter', 'pyramid_alchemy', 'pyramid_routesalchemy', - 'pyramid_zodb'): + for name in templates: test = TemplateTest() test.install(name) -- cgit v1.2.3