summaryrefslogtreecommitdiff
path: root/template_tests.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-01-25 04:55:52 -0500
committerChris McDonough <chrism@plope.com>2011-01-25 04:55:52 -0500
commitbac455263145b1b112d7627205f4c8aa85601cb7 (patch)
treeda57c86e5b9a004de8d1c3b23f0bd011a01ed576 /template_tests.py
parent965fe115c4b5a4bc47939cf48bc36c24ffba8f0f (diff)
downloadpyramid-bac455263145b1b112d7627205f4c8aa85601cb7.tar.gz
pyramid-bac455263145b1b112d7627205f4c8aa85601cb7.tar.bz2
pyramid-bac455263145b1b112d7627205f4c8aa85601cb7.zip
automate template testing
Diffstat (limited to 'template_tests.py')
-rw-r--r--template_tests.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/template_tests.py b/template_tests.py
new file mode 100644
index 000000000..6860a8bcb
--- /dev/null
+++ b/template_tests.py
@@ -0,0 +1,59 @@
+import httplib
+import os
+import pkg_resources
+import shutil
+import subprocess
+import tempfile
+import time
+
+class TemplateTest(object):
+ def make_venv(self, directory):
+ import virtualenv
+ import sys
+ from virtualenv import Logger
+ logger = Logger([(Logger.level_for_integer(2), sys.stdout)])
+ virtualenv.logger = logger
+ virtualenv.create_environment(directory,
+ site_packages=False,
+ clear=False,
+ unzip_setuptools=True,
+ use_distribute=False)
+ def install(self, tmpl_name):
+ try:
+ self.old_cwd = os.getcwd()
+ self.directory = tempfile.mkdtemp()
+ self.make_venv(self.directory)
+ os.chdir(pkg_resources.get_distribution('pyramid').location)
+ subprocess.check_call(
+ [os.path.join(self.directory, 'bin', 'python'),
+ 'setup.py', 'develop'])
+ os.chdir(self.directory)
+
+ subprocess.check_call(['bin/paster', 'create', '-t', tmpl_name,
+ 'Dingle'])
+ os.chdir('Dingle')
+ py = os.path.join(self.directory, 'bin', 'python')
+ subprocess.check_call([py, 'setup.py', 'install'])
+ paster = os.path.join(self.directory, 'bin', 'paster')
+ proc = subprocess.Popen([paster, 'serve', 'development.ini'])
+ try:
+ time.sleep(5)
+ proc.poll()
+ if proc.returncode is not None:
+ raise RuntimeError('didnt start')
+ conn = httplib.HTTPConnection('localhost:6543')
+ conn.request('GET', '/')
+ resp = conn.getresponse()
+ assert(resp.status == 200)
+ finally:
+ proc.terminate()
+ finally:
+ shutil.rmtree(self.directory)
+ os.chdir(self.old_cwd)
+
+if __name__ == '__main__':
+ for name in ('pyramid_starter', 'pyramid_alchemy', 'pyramid_routesalchemy',
+ 'pyramid_zodb'):
+ test = TemplateTest()
+ test.install(name)
+