summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2018-10-31 01:46:25 -0500
committerMichael Merickel <michael@merickel.org>2018-10-31 01:46:25 -0500
commit4aa2eb5f970b812a96480e2cd7c18c1103b844c8 (patch)
treeeb1406080661b3cf8b5b3ad2935992863b654f00 /tests
parent26ff2bf625f426f90abb313e9e028fc16308d105 (diff)
downloadpyramid-4aa2eb5f970b812a96480e2cd7c18c1103b844c8.tar.gz
pyramid-4aa2eb5f970b812a96480e2cd7c18c1103b844c8.tar.bz2
pyramid-4aa2eb5f970b812a96480e2cd7c18c1103b844c8.zip
initial work removing pcreate
Diffstat (limited to 'tests')
-rw-r--r--tests/test_scaffolds/__init__.py1
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/.badfile0
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/__init__.py_tmpl12
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/resources.py3
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/static/favicon.icobin1406 -> 0 bytes
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/static/footerbg.pngbin333 -> 0 bytes
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/static/headerbg.pngbin203 -> 0 bytes
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/static/ie6.css8
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/static/middlebg.pngbin2797 -> 0 bytes
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/static/pylons.css65
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/static/pyramid-small.pngbin7044 -> 0 bytes
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/static/pyramid.pngbin33055 -> 0 bytes
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/static/transparent.gifbin49 -> 0 bytes
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/templates/mytemplate.pt_tmpl76
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/test_no_content.py_tmpl0
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/tests.py_tmpl16
-rw-r--r--tests/test_scaffolds/fixture_scaffold/+package+/views.py_tmpl2
-rw-r--r--tests/test_scaffolds/fixture_scaffold/CHANGES.txt_tmpl4
-rw-r--r--tests/test_scaffolds/fixture_scaffold/MANIFEST.in_tmpl2
-rw-r--r--tests/test_scaffolds/fixture_scaffold/README.txt_tmpl1
-rw-r--r--tests/test_scaffolds/fixture_scaffold/development.ini_tmpl45
-rw-r--r--tests/test_scaffolds/fixture_scaffold/production.ini_tmpl44
-rw-r--r--tests/test_scaffolds/fixture_scaffold/setup.py_tmpl38
-rw-r--r--tests/test_scaffolds/test_copydir.py574
-rw-r--r--tests/test_scaffolds/test_init.py22
-rw-r--r--tests/test_scaffolds/test_template.py174
-rw-r--r--tests/test_scripts/test_pcreate.py409
27 files changed, 0 insertions, 1496 deletions
diff --git a/tests/test_scaffolds/__init__.py b/tests/test_scaffolds/__init__.py
deleted file mode 100644
index 5bb534f79..000000000
--- a/tests/test_scaffolds/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# package
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/.badfile b/tests/test_scaffolds/fixture_scaffold/+package+/.badfile
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/.badfile
+++ /dev/null
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/__init__.py_tmpl b/tests/test_scaffolds/fixture_scaffold/+package+/__init__.py_tmpl
deleted file mode 100644
index d763b2435..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/__init__.py_tmpl
+++ /dev/null
@@ -1,12 +0,0 @@
-from pyramid.config import Configurator
-from {{package}}.resources import Root
-
-def main(global_config, **settings):
- """ This function returns a Pyramid WSGI application.
- """
- config = Configurator(root_factory=Root, settings=settings)
- config.add_view('{{package}}.views.my_view',
- context='{{package}}:resources.Root',
- renderer='{{package}}:templates/mytemplate.pt')
- config.add_static_view('static', '{{package}}:static', cache_max_age=3600)
- return config.make_wsgi_app()
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/resources.py b/tests/test_scaffolds/fixture_scaffold/+package+/resources.py
deleted file mode 100644
index 3d811895c..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/resources.py
+++ /dev/null
@@ -1,3 +0,0 @@
-class Root(object):
- def __init__(self, request):
- self.request = request
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/static/favicon.ico b/tests/test_scaffolds/fixture_scaffold/+package+/static/favicon.ico
deleted file mode 100644
index 71f837c9e..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/static/favicon.ico
+++ /dev/null
Binary files differ
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/static/footerbg.png b/tests/test_scaffolds/fixture_scaffold/+package+/static/footerbg.png
deleted file mode 100644
index 1fbc873da..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/static/footerbg.png
+++ /dev/null
Binary files differ
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/static/headerbg.png b/tests/test_scaffolds/fixture_scaffold/+package+/static/headerbg.png
deleted file mode 100644
index 0596f2020..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/static/headerbg.png
+++ /dev/null
Binary files differ
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/static/ie6.css b/tests/test_scaffolds/fixture_scaffold/+package+/static/ie6.css
deleted file mode 100644
index b7c8493d8..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/static/ie6.css
+++ /dev/null
@@ -1,8 +0,0 @@
-* html img,
-* html .png{position:relative;behavior:expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none",
-this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "',sizingMethod='image')",
-this.src = "static/transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''),
-this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "',sizingMethod='crop')",
-this.runtimeStyle.backgroundImage = "none")),this.pngSet=true)
-);}
-#wrap{display:table;height:100%}
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/static/middlebg.png b/tests/test_scaffolds/fixture_scaffold/+package+/static/middlebg.png
deleted file mode 100644
index 2369cfb7d..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/static/middlebg.png
+++ /dev/null
Binary files differ
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/static/pylons.css b/tests/test_scaffolds/fixture_scaffold/+package+/static/pylons.css
deleted file mode 100644
index c54499ddd..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/static/pylons.css
+++ /dev/null
@@ -1,65 +0,0 @@
-html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;/* 16px */
-vertical-align:baseline;background:transparent;}
-body{line-height:1;}
-ol,ul{list-style:none;}
-blockquote,q{quotes:none;}
-blockquote:before,blockquote:after,q:before,q:after{content:'';content:none;}
-:focus{outline:0;}
-ins{text-decoration:none;}
-del{text-decoration:line-through;}
-table{border-collapse:collapse;border-spacing:0;}
-sub{vertical-align:sub;font-size:smaller;line-height:normal;}
-sup{vertical-align:super;font-size:smaller;line-height:normal;}
-ul,menu,dir{display:block;list-style-type:disc;margin:1em 0;padding-left:40px;}
-ol{display:block;list-style-type:decimal-leading-zero;margin:1em 0;padding-left:40px;}
-li{display:list-item;}
-ul ul,ul ol,ul dir,ul menu,ul dl,ol ul,ol ol,ol dir,ol menu,ol dl,dir ul,dir ol,dir dir,dir menu,dir dl,menu ul,menu ol,menu dir,menu menu,menu dl,dl ul,dl ol,dl dir,dl menu,dl dl{margin-top:0;margin-bottom:0;}
-ol ul,ul ul,menu ul,dir ul,ol menu,ul menu,menu menu,dir menu,ol dir,ul dir,menu dir,dir dir{list-style-type:circle;}
-ol ol ul,ol ul ul,ol menu ul,ol dir ul,ol ol menu,ol ul menu,ol menu menu,ol dir menu,ol ol dir,ol ul dir,ol menu dir,ol dir dir,ul ol ul,ul ul ul,ul menu ul,ul dir ul,ul ol menu,ul ul menu,ul menu menu,ul dir menu,ul ol dir,ul ul dir,ul menu dir,ul dir dir,menu ol ul,menu ul ul,menu menu ul,menu dir ul,menu ol menu,menu ul menu,menu menu menu,menu dir menu,menu ol dir,menu ul dir,menu menu dir,menu dir dir,dir ol ul,dir ul ul,dir menu ul,dir dir ul,dir ol menu,dir ul menu,dir menu menu,dir dir menu,dir ol dir,dir ul dir,dir menu dir,dir dir dir{list-style-type:square;}
-.hidden{display:none;}
-p{line-height:1.5em;}
-h1{font-size:1.75em;line-height:1.7em;font-family:helvetica,verdana;}
-h2{font-size:1.5em;line-height:1.7em;font-family:helvetica,verdana;}
-h3{font-size:1.25em;line-height:1.7em;font-family:helvetica,verdana;}
-h4{font-size:1em;line-height:1.7em;font-family:helvetica,verdana;}
-html,body{width:100%;height:100%;}
-body{margin:0;padding:0;background-color:#ffffff;position:relative;font:16px/24px "NobileRegular","Lucida Grande",Lucida,Verdana,sans-serif;}
-a{color:#1b61d6;text-decoration:none;}
-a:hover{color:#e88f00;text-decoration:underline;}
-body h1,
-body h2,
-body h3,
-body h4,
-body h5,
-body h6{font-family:"NeutonRegular","Lucida Grande",Lucida,Verdana,sans-serif;font-weight:normal;color:#373839;font-style:normal;}
-#wrap{min-height:100%;}
-#header,#footer{width:100%;color:#ffffff;height:40px;position:absolute;text-align:center;line-height:40px;overflow:hidden;font-size:12px;vertical-align:middle;}
-#header{background:#000000;top:0;font-size:14px;}
-#footer{bottom:0;background:#000000 url(footerbg.png) repeat-x 0 top;position:relative;margin-top:-40px;clear:both;}
-.header,.footer{width:750px;margin-right:auto;margin-left:auto;}
-.wrapper{width:100%}
-#top,#top-small,#bottom{width:100%;}
-#top{color:#000000;height:230px;background:#ffffff url(headerbg.png) repeat-x 0 top;position:relative;}
-#top-small{color:#000000;height:60px;background:#ffffff url(headerbg.png) repeat-x 0 top;position:relative;}
-#bottom{color:#222;background-color:#ffffff;}
-.top,.top-small,.middle,.bottom{width:750px;margin-right:auto;margin-left:auto;}
-.top{padding-top:40px;}
-.top-small{padding-top:10px;}
-#middle{width:100%;height:100px;background:url(middlebg.png) repeat-x;border-top:2px solid #ffffff;border-bottom:2px solid #b2b2b2;}
-.app-welcome{margin-top:25px;}
-.app-name{color:#000000;font-weight:bold;}
-.bottom{padding-top:50px;}
-#left{width:350px;float:left;padding-right:25px;}
-#right{width:350px;float:right;padding-left:25px;}
-.align-left{text-align:left;}
-.align-right{text-align:right;}
-.align-center{text-align:center;}
-ul.links{margin:0;padding:0;}
-ul.links li{list-style-type:none;font-size:14px;}
-form{border-style:none;}
-fieldset{border-style:none;}
-input{color:#222;border:1px solid #ccc;font-family:sans-serif;font-size:12px;line-height:16px;}
-input[type=text],input[type=password]{width:205px;}
-input[type=submit]{background-color:#ddd;font-weight:bold;}
-/*Opera Fix*/
-body:before{content:"";height:100%;float:left;width:0;margin-top:-32767px;}
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/static/pyramid-small.png b/tests/test_scaffolds/fixture_scaffold/+package+/static/pyramid-small.png
deleted file mode 100644
index a5bc0ade7..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/static/pyramid-small.png
+++ /dev/null
Binary files differ
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/static/pyramid.png b/tests/test_scaffolds/fixture_scaffold/+package+/static/pyramid.png
deleted file mode 100644
index 347e05549..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/static/pyramid.png
+++ /dev/null
Binary files differ
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/static/transparent.gif b/tests/test_scaffolds/fixture_scaffold/+package+/static/transparent.gif
deleted file mode 100644
index 0341802e5..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/static/transparent.gif
+++ /dev/null
Binary files differ
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/templates/mytemplate.pt_tmpl b/tests/test_scaffolds/fixture_scaffold/+package+/templates/mytemplate.pt_tmpl
deleted file mode 100644
index f4d98ec29..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/templates/mytemplate.pt_tmpl
+++ /dev/null
@@ -1,76 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal">
-<head>
- <title>The Pyramid Web Framework</title>
- <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
- <meta name="keywords" content="python web application" />
- <meta name="description" content="pyramid web application" />
- <link rel="shortcut icon" href="${request.static_url('{{package}}:static/favicon.ico')}" />
- <link rel="stylesheet" href="${request.static_url('{{package}}:static/pylons.css')}" type="text/css" media="screen" charset="utf-8" />
- <link rel="stylesheet" href="http://static.pylonsproject.org/fonts/nobile/stylesheet.css" media="screen" />
- <link rel="stylesheet" href="http://static.pylonsproject.org/fonts/neuton/stylesheet.css" media="screen" />
- <!--[if lte IE 6]>
- <link rel="stylesheet" href="${request.static_url('{{package}}:static/ie6.css')}" type="text/css" media="screen" charset="utf-8" />
- <![endif]-->
-</head>
-<body>
- <div id="wrap">
- <div id="top">
- <div class="top align-center">
- <div><img src="${request.static_url('{{package}}:static/pyramid.png')}" width="750" height="169" alt="pyramid"/></div>
- </div>
- </div>
- <div id="middle">
- <div class="middle align-center">
- <p class="app-welcome">
- Welcome to <span class="app-name">${project}</span>, an application generated by<br/>
- the Pyramid Web Framework.
- </p>
- </div>
- </div>
- <div id="bottom">
- <div class="bottom">
- <div id="left" class="align-right">
- <h2>Search documentation</h2>
- <form method="get" action="http://docs.pylonsproject.org/projects/pyramid/current/search.html">
- <input type="text" id="q" name="q" value="" />
- <input type="submit" id="x" value="Go" />
- </form>
- </div>
- <div id="right" class="align-left">
- <h2>Pyramid links</h2>
- <ul class="links">
- <li>
- <a href="https://pylonsproject.org">Pylons Website</a>
- </li>
- <li>
- <a href="http://docs.pylonsproject.org/projects/pyramid/current/#narrative-documentation">Narrative Documentation</a>
- </li>
- <li>
- <a href="http://docs.pylonsproject.org/projects/pyramid/current/#api-documentation">API Documentation</a>
- </li>
- <li>
- <a href="http://docs.pylonsproject.org/projects/pyramid/current/#tutorials">Tutorials</a>
- </li>
- <li>
- <a href="http://docs.pylonsproject.org/projects/pyramid/current/#change-history">Change History</a>
- </li>
- <li>
- <a href="http://docs.pylonsproject.org/projects/pyramid/current/#sample-applications">Sample Applications</a>
- </li>
- <li>
- <a href="http://docs.pylonsproject.org/projects/pyramid/current/#support-and-development">Support and Development</a>
- </li>
- <li>
- <a href="irc://irc.freenode.net#pyramid">IRC Channel</a>
- </li>
- </ul>
- </div>
- </div>
- </div>
- </div>
- <div id="footer">
- <div class="footer">&copy; Copyright 2008-2011, Agendaless Consulting.</div>
- </div>
-</body>
-</html>
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/test_no_content.py_tmpl b/tests/test_scaffolds/fixture_scaffold/+package+/test_no_content.py_tmpl
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/test_no_content.py_tmpl
+++ /dev/null
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/tests.py_tmpl b/tests/test_scaffolds/fixture_scaffold/+package+/tests.py_tmpl
deleted file mode 100644
index 1627bf015..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/tests.py_tmpl
+++ /dev/null
@@ -1,16 +0,0 @@
-import unittest
-
-from pyramid import testing
-
-class ViewTests(unittest.TestCase):
- def setUp(self):
- self.config = testing.setUp()
-
- def tearDown(self):
- testing.tearDown()
-
- def test_my_view(self):
- from {{package}}.views import my_view
- request = testing.DummyRequest()
- info = my_view(request)
- self.assertEqual(info['project'], '{{project}}')
diff --git a/tests/test_scaffolds/fixture_scaffold/+package+/views.py_tmpl b/tests/test_scaffolds/fixture_scaffold/+package+/views.py_tmpl
deleted file mode 100644
index 12ed8832d..000000000
--- a/tests/test_scaffolds/fixture_scaffold/+package+/views.py_tmpl
+++ /dev/null
@@ -1,2 +0,0 @@
-def my_view(request):
- return {'project':'{{project}}'}
diff --git a/tests/test_scaffolds/fixture_scaffold/CHANGES.txt_tmpl b/tests/test_scaffolds/fixture_scaffold/CHANGES.txt_tmpl
deleted file mode 100644
index 35a34f332..000000000
--- a/tests/test_scaffolds/fixture_scaffold/CHANGES.txt_tmpl
+++ /dev/null
@@ -1,4 +0,0 @@
-0.0
----
-
-- Initial version
diff --git a/tests/test_scaffolds/fixture_scaffold/MANIFEST.in_tmpl b/tests/test_scaffolds/fixture_scaffold/MANIFEST.in_tmpl
deleted file mode 100644
index 0ff6eb7a0..000000000
--- a/tests/test_scaffolds/fixture_scaffold/MANIFEST.in_tmpl
+++ /dev/null
@@ -1,2 +0,0 @@
-include *.txt *.ini *.cfg *.rst
-recursive-include {{package}} *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml
diff --git a/tests/test_scaffolds/fixture_scaffold/README.txt_tmpl b/tests/test_scaffolds/fixture_scaffold/README.txt_tmpl
deleted file mode 100644
index 40f98d14a..000000000
--- a/tests/test_scaffolds/fixture_scaffold/README.txt_tmpl
+++ /dev/null
@@ -1 +0,0 @@
-{{project}} README
diff --git a/tests/test_scaffolds/fixture_scaffold/development.ini_tmpl b/tests/test_scaffolds/fixture_scaffold/development.ini_tmpl
deleted file mode 100644
index 01c504f99..000000000
--- a/tests/test_scaffolds/fixture_scaffold/development.ini_tmpl
+++ /dev/null
@@ -1,45 +0,0 @@
-[app:main]
-use = egg:{{project}}
-
-pyramid.reload_templates = true
-pyramid.debug_authorization = false
-pyramid.debug_notfound = false
-pyramid.debug_routematch = false
-pyramid.debug_templates = true
-pyramid.default_locale_name = en
-pyramid.includes = pyramid_debugtoolbar
-
-[server:main]
-use = egg:pyramid#wsgiref
-listen = *:6543
-
-# Begin logging configuration
-
-[loggers]
-keys = root, {{package_logger}}
-
-[handlers]
-keys = console
-
-[formatters]
-keys = generic
-
-[logger_root]
-level = INFO
-handlers = console
-
-[logger_{{package_logger}}]
-level = DEBUG
-handlers =
-qualname = {{package}}
-
-[handler_console]
-class = StreamHandler
-args = (sys.stderr,)
-level = NOTSET
-formatter = generic
-
-[formatter_generic]
-format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/tests/test_scaffolds/fixture_scaffold/production.ini_tmpl b/tests/test_scaffolds/fixture_scaffold/production.ini_tmpl
deleted file mode 100644
index becd3aa76..000000000
--- a/tests/test_scaffolds/fixture_scaffold/production.ini_tmpl
+++ /dev/null
@@ -1,44 +0,0 @@
-[app:main]
-use = egg:{{project}}
-
-pyramid.reload_templates = false
-pyramid.debug_authorization = false
-pyramid.debug_notfound = false
-pyramid.debug_routematch = false
-pyramid.debug_templates = false
-pyramid.default_locale_name = en
-
-[server:main]
-use = egg:pyramid#wsgiref
-listen = *:6543
-
-# Begin logging configuration
-
-[loggers]
-keys = root, {{package_logger}}
-
-[handlers]
-keys = console
-
-[formatters]
-keys = generic
-
-[logger_root]
-level = WARN
-handlers = console
-
-[logger_{{package_logger}}]
-level = WARN
-handlers =
-qualname = {{package}}
-
-[handler_console]
-class = StreamHandler
-args = (sys.stderr,)
-level = NOTSET
-formatter = generic
-
-[formatter_generic]
-format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
-
-# End logging configuration
diff --git a/tests/test_scaffolds/fixture_scaffold/setup.py_tmpl b/tests/test_scaffolds/fixture_scaffold/setup.py_tmpl
deleted file mode 100644
index ee9fd5fda..000000000
--- a/tests/test_scaffolds/fixture_scaffold/setup.py_tmpl
+++ /dev/null
@@ -1,38 +0,0 @@
-import os
-
-from setuptools import setup, find_packages
-
-here = os.path.abspath(os.path.dirname(__file__))
-with open(os.path.join(here, 'README.txt')) as f:
- README = f.read()
-with open(os.path.join(here, 'CHANGES.txt')) as f:
- CHANGES = f.read()
-
-requires = ['pyramid', 'pyramid_debugtoolbar']
-
-setup(name='{{project}}',
- version='0.0',
- description='{{project}}',
- long_description=README + '\n\n' + CHANGES,
- classifiers=[
- "Programming Language :: Python",
- "Framework :: Pylons",
- "Topic :: Internet :: WWW/HTTP",
- "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
- ],
- author='',
- author_email='',
- url='',
- keywords='web pyramid pylons',
- packages=find_packages(),
- include_package_data=True,
- zip_safe=False,
- install_requires=requires,
- tests_require=requires,
- test_suite="{{package}}",
- entry_points = """\
- [paste.app_factory]
- main = {{package}}:main
- """,
- )
-
diff --git a/tests/test_scaffolds/test_copydir.py b/tests/test_scaffolds/test_copydir.py
deleted file mode 100644
index 1f046f9e8..000000000
--- a/tests/test_scaffolds/test_copydir.py
+++ /dev/null
@@ -1,574 +0,0 @@
-# -*- coding: utf-8 -*-
-import unittest
-import os
-import pkg_resources
-
-
-class Test_copy_dir(unittest.TestCase):
- def setUp(self):
- import tempfile
- from pyramid.compat import NativeIO
-
- self.dirname = tempfile.mkdtemp()
- self.out = NativeIO()
- self.fixturetuple = ('tests.test_scaffolds', 'fixture_scaffold')
-
- def tearDown(self):
- import shutil
-
- shutil.rmtree(self.dirname, ignore_errors=True)
- self.out.close()
-
- def _callFUT(self, *arg, **kw):
- kw['out_'] = self.out
- from pyramid.scaffolds.copydir import copy_dir
-
- return copy_dir(*arg, **kw)
-
- def test_copy_source_as_pkg_resource(self):
- vars = {'package': 'mypackage'}
- self._callFUT(
- self.fixturetuple,
- self.dirname,
- vars,
- 1,
- False,
- template_renderer=dummy_template_renderer,
- )
- result = self.out.getvalue()
- self.assertTrue('Creating' in result)
- self.assertTrue(
- 'Copying fixture_scaffold/+package+/__init__.py_tmpl to' in result
- )
- source = pkg_resources.resource_filename(
- 'tests.test_scaffolds',
- 'fixture_scaffold/+package+/__init__.py_tmpl',
- )
- target = os.path.join(self.dirname, 'mypackage', '__init__.py')
- with open(target, 'r') as f:
- tcontent = f.read()
- with open(source, 'r') as f:
- scontent = f.read()
- self.assertEqual(scontent, tcontent)
-
- def test_copy_source_as_dirname(self):
- vars = {'package': 'mypackage'}
- source = pkg_resources.resource_filename(*self.fixturetuple)
- self._callFUT(
- source,
- self.dirname,
- vars,
- 1,
- False,
- template_renderer=dummy_template_renderer,
- )
- result = self.out.getvalue()
- self.assertTrue('Creating' in result)
- self.assertTrue('Copying __init__.py_tmpl to' in result)
- source = pkg_resources.resource_filename(
- 'tests.test_scaffolds',
- 'fixture_scaffold/+package+/__init__.py_tmpl',
- )
- target = os.path.join(self.dirname, 'mypackage', '__init__.py')
- with open(target, 'r') as f:
- tcontent = f.read()
- with open(source, 'r') as f:
- scontent = f.read()
- self.assertEqual(scontent, tcontent)
-
- def test_content_is_same_message(self):
- vars = {'package': 'mypackage'}
- source = pkg_resources.resource_filename(*self.fixturetuple)
- self._callFUT(
- source,
- self.dirname,
- vars,
- 2,
- False,
- template_renderer=dummy_template_renderer,
- )
- self._callFUT(
- source,
- self.dirname,
- vars,
- 2,
- False,
- template_renderer=dummy_template_renderer,
- )
- result = self.out.getvalue()
- self.assertTrue(
- '%s already exists (same content)'
- % os.path.join(self.dirname, 'mypackage', '__init__.py')
- in result
- )
-
- def test_direxists_message(self):
- vars = {'package': 'mypackage'}
- source = pkg_resources.resource_filename(*self.fixturetuple)
- # if not os.path.exists(self.dirname):
- # os.mkdir(self.dirname)
- self._callFUT(
- source,
- self.dirname,
- vars,
- 2,
- False,
- template_renderer=dummy_template_renderer,
- )
- result = self.out.getvalue()
- self.assertTrue('Directory %s exists' % self.dirname in result, result)
-
- def test_overwrite_false(self):
- vars = {'package': 'mypackage'}
- source = pkg_resources.resource_filename(*self.fixturetuple)
- self._callFUT(
- source,
- self.dirname,
- vars,
- 1,
- False,
- overwrite=False,
- template_renderer=dummy_template_renderer,
- )
- # toplevel file
- toplevel = os.path.join(self.dirname, 'mypackage', '__init__.py')
- with open(toplevel, 'w') as f:
- f.write('These are the words you are looking for.')
- # sub directory file
- sub = os.path.join(
- self.dirname, 'mypackage', 'templates', 'mytemplate.pt'
- )
- with open(sub, 'w') as f:
- f.write('These are the words you are looking for.')
- self._callFUT(
- source,
- self.dirname,
- vars,
- 1,
- False,
- overwrite=False,
- template_renderer=dummy_template_renderer,
- )
- with open(toplevel, 'r') as f:
- tcontent = f.read()
- self.assertEqual('These are the words you are looking for.', tcontent)
- with open(sub, 'r') as f:
- tcontent = f.read()
- self.assertEqual('These are the words you are looking for.', tcontent)
-
- def test_overwrite_true(self):
- vars = {'package': 'mypackage'}
- source = pkg_resources.resource_filename(*self.fixturetuple)
- self._callFUT(
- source,
- self.dirname,
- vars,
- 1,
- False,
- overwrite=True,
- template_renderer=dummy_template_renderer,
- )
- # toplevel file
- toplevel = os.path.join(self.dirname, 'mypackage', '__init__.py')
- with open(toplevel, 'w') as f:
- f.write('These are not the words you are looking for.')
- # sub directory file
- sub = os.path.join(
- self.dirname, 'mypackage', 'templates', 'mytemplate.pt'
- )
- with open(sub, 'w') as f:
- f.write('These are not the words you are looking for.')
- self._callFUT(
- source,
- self.dirname,
- vars,
- 1,
- False,
- overwrite=True,
- template_renderer=dummy_template_renderer,
- )
- with open(toplevel, 'r') as f:
- tcontent = f.read()
- self.assertNotEqual(
- 'These are not the words you are looking for.', tcontent
- )
- with open(sub, 'r') as f:
- tcontent = f.read()
- self.assertNotEqual(
- 'These are not the words you are looking for.', tcontent
- )
-
- def test_detect_SkipTemplate(self):
- vars = {'package': 'mypackage'}
- source = pkg_resources.resource_filename(*self.fixturetuple)
-
- def dummy_template_renderer(*args, **kwargs):
- from pyramid.scaffolds.copydir import SkipTemplate
-
- raise SkipTemplate
-
- self._callFUT(
- source,
- self.dirname,
- vars,
- 1,
- False,
- template_renderer=dummy_template_renderer,
- )
-
- def test_query_interactive(self):
- from pyramid.scaffolds import copydir
-
- vars = {'package': 'mypackage'}
- source = pkg_resources.resource_filename(*self.fixturetuple)
- self._callFUT(
- source,
- self.dirname,
- vars,
- 1,
- False,
- overwrite=False,
- template_renderer=dummy_template_renderer,
- )
- target = os.path.join(self.dirname, 'mypackage', '__init__.py')
- with open(target, 'w') as f:
- f.write('These are not the words you are looking for.')
- # We need query_interactive to return False in order to force
- # execution of a branch
- original_code_object = copydir.query_interactive
- copydir.query_interactive = lambda *args, **kwargs: False
- self._callFUT(
- source,
- self.dirname,
- vars,
- 1,
- False,
- interactive=True,
- overwrite=False,
- template_renderer=dummy_template_renderer,
- )
- copydir.query_interactive = original_code_object
-
-
-class Test_raise_SkipTemplate(unittest.TestCase):
- def _callFUT(self, *arg, **kw):
- from pyramid.scaffolds.copydir import skip_template
-
- return skip_template(*arg, **kw)
-
- def test_raise_SkipTemplate(self):
- from pyramid.scaffolds.copydir import SkipTemplate
-
- self.assertRaises(SkipTemplate, self._callFUT, True, "exc-message")
-
-
-class Test_makedirs(unittest.TestCase):
- def _callFUT(self, *arg, **kw):
- from pyramid.scaffolds.copydir import makedirs
-
- return makedirs(*arg, **kw)
-
- def test_makedirs_parent_dir(self):
- import shutil
- import tempfile
-
- tmpdir = tempfile.mkdtemp()
- target = os.path.join(tmpdir, 'nonexistent_subdir')
- self._callFUT(target, 2, None)
- shutil.rmtree(tmpdir)
-
- def test_makedirs_no_parent_dir(self):
- import shutil
- import tempfile
-
- tmpdir = tempfile.mkdtemp()
- target = os.path.join(tmpdir, 'nonexistent_subdir', 'non2')
- self._callFUT(target, 2, None)
- shutil.rmtree(tmpdir)
-
-
-class Test_support_functions(unittest.TestCase):
- def _call_html_quote(self, *arg, **kw):
- from pyramid.scaffolds.copydir import html_quote
-
- return html_quote(*arg, **kw)
-
- def _call_url_quote(self, *arg, **kw):
- from pyramid.scaffolds.copydir import url_quote
-
- return url_quote(*arg, **kw)
-
- def _call_test(self, *arg, **kw):
- from pyramid.scaffolds.copydir import test
-
- return test(*arg, **kw)
-
- def test_html_quote(self):
- import string
-
- s = None
- self.assertEqual(self._call_html_quote(s), '')
- s = string.ascii_letters
- self.assertEqual(self._call_html_quote(s), s)
- s = "Λεμεσός"
- self.assertEqual(
- self._call_url_quote(s),
- "%CE%9B%CE%B5%CE%BC%CE%B5%CF%83%CF%8C%CF%82",
- )
-
- def test_url_quote(self):
- import string
-
- s = None
- self.assertEqual(self._call_url_quote(s), '')
- s = string.ascii_letters
- self.assertEqual(self._call_url_quote(s), s)
- s = "Λεμεσός"
- self.assertEqual(
- self._call_url_quote(s),
- "%CE%9B%CE%B5%CE%BC%CE%B5%CF%83%CF%8C%CF%82",
- )
-
- def test_test(self):
- conf = True
- true_cond = "faked"
- self.assertEqual(
- self._call_test(conf, true_cond, false_cond=None), "faked"
- )
- conf = False
- self.assertEqual(
- self._call_test(conf, true_cond, false_cond="alsofaked"),
- "alsofaked",
- )
-
-
-class Test_should_skip_file(unittest.TestCase):
- def _callFUT(self, *arg, **kw):
- from pyramid.scaffolds.copydir import should_skip_file
-
- return should_skip_file(*arg, **kw)
-
- def test_should_skip_dot_hidden_file(self):
- self.assertEqual(
- self._callFUT('.a_filename'), 'Skipping hidden file %(filename)s'
- )
-
- def test_should_skip_backup_file(self):
- for name in ('a_filename~', 'a_filename.bak'):
- self.assertEqual(
- self._callFUT(name), 'Skipping backup file %(filename)s'
- )
-
- def test_should_skip_bytecompiled_file(self):
- for name in ('afilename.pyc', 'afilename.pyo'):
- extension = os.path.splitext(name)[1]
- self.assertEqual(
- self._callFUT(name),
- 'Skipping %s file ' % extension + '%(filename)s',
- )
-
- def test_should_skip_jython_class_file(self):
- self.assertEqual(
- self._callFUT('afilename$py.class'),
- 'Skipping $py.class file %(filename)s',
- )
-
- def test_should_skip_version_control_directory(self):
- for name in ('CVS', '_darcs'):
- self.assertEqual(
- self._callFUT(name),
- 'Skipping version control directory %(filename)s',
- )
-
- def test_valid_file_is_not_skipped(self):
- self.assertEqual(self._callFUT('a_filename'), None)
-
-
-class RawInputMockObject(object):
- count = 0
-
- def __init__(self, fake_input):
- self.input = fake_input
- self.count = 0
-
- def __call__(self, prompt):
- # Don't cycle endlessly.
- self.count += 1
- if self.count > 1:
- return 'y'
- else:
- return self.input
-
-
-class Test_query_interactive(unittest.TestCase):
- def setUp(self):
- import tempfile
- from pyramid.compat import NativeIO
-
- self.dirname = tempfile.mkdtemp()
- self.out = NativeIO()
- self.fixturetuple = ('tests.test_scaffolds', 'fixture_scaffold')
- self.src_content = """\
-These are not the droids
-that you are looking for."""
- self.dest_content = """\
-These are the droids for
-whom you are looking;
-now you have found them."""
- self.src_fn = os.path.join(self.dirname, 'mypackage', '__init__.py')
- self.dest_fn = os.path.join(self.dirname, 'mypackage', '__init__.py')
- # query_interactive is only normally executed when the destination
- # is discovered to be already occupied by existing files, so ...
- # create the required occupancy.
- from pyramid.scaffolds.copydir import copy_dir
-
- copy_dir(
- self.fixturetuple,
- self.dirname,
- {'package': 'mypackage'},
- 0,
- False,
- template_renderer=dummy_template_renderer,
- )
-
- def tearDown(self):
- import shutil
-
- shutil.rmtree(self.dirname, ignore_errors=True)
- self.out.close()
-
- def _callFUT(self, *arg, **kw):
- from pyramid.scaffolds.copydir import query_interactive
-
- return query_interactive(*arg, **kw)
-
- def test_query_interactive_0y(self):
- from pyramid.scaffolds import copydir
-
- copydir.input_ = RawInputMockObject("y")
- self._callFUT(
- self.src_fn,
- self.dest_fn,
- self.src_content,
- self.dest_content,
- simulate=False,
- out_=self.out,
- )
- self.assertTrue("Replace" in self.out.getvalue())
-
- def test_query_interactive_1n(self):
- from pyramid.scaffolds import copydir
-
- copydir.input_ = RawInputMockObject("n")
- self._callFUT(
- self.src_fn,
- self.dest_fn,
- self.src_content,
- '\n'.join(self.dest_content.split('\n')[:-1]),
- simulate=False,
- out_=self.out,
- )
- self.assertTrue("Replace" in self.out.getvalue())
-
- def test_query_interactive_2b(self):
- from pyramid.scaffolds import copydir
-
- copydir.input_ = RawInputMockObject("b")
- with open(
- os.path.join(self.dirname, 'mypackage', '__init__.py.bak'), 'w'
- ) as fp:
- fp.write("")
- fp.close()
- self._callFUT(
- self.src_fn,
- self.dest_fn,
- self.dest_content,
- self.src_content,
- simulate=False,
- out_=self.out,
- )
- self.assertTrue("Backing up" in self.out.getvalue())
-
- def test_query_interactive_3d(self):
- from pyramid.scaffolds import copydir
-
- copydir.input_ = RawInputMockObject("d")
- self._callFUT(
- self.src_fn,
- self.dest_fn,
- self.dest_content,
- self.src_content,
- simulate=False,
- out_=self.out,
- )
- output = self.out.getvalue()
- # The useful text in self.out gets wiped out on the second
- # call to raw_input, otherwise the test could be made
- # more usefully precise...
- # print("3d", output)
- # self.assertTrue("@@" in output, output)
- self.assertTrue("Replace" in output)
-
- def test_query_interactive_4dc(self):
- from pyramid.scaffolds import copydir
-
- copydir.input_ = RawInputMockObject("dc")
- self._callFUT(
- self.src_fn,
- self.dest_fn,
- self.dest_content,
- self.src_content,
- simulate=False,
- out_=self.out,
- )
- output = self.out.getvalue()
- # The useful text in self.out gets wiped out on the second
- # call to raw_input, otherwise, the test could be made
- # more usefully precise...
- # print("4dc", output)
- # self.assertTrue("***" in output, output)
- self.assertTrue("Replace" in output)
-
- def test_query_interactive_5allbad(self):
- from pyramid.scaffolds import copydir
-
- copydir.input_ = RawInputMockObject("all z")
- self._callFUT(
- self.src_fn,
- self.dest_fn,
- self.src_content,
- self.dest_content,
- simulate=False,
- out_=self.out,
- )
- output = self.out.getvalue()
- # The useful text in self.out gets wiped out on the second
- # call to raw_input, otherwise the test could be made
- # more usefully precise...
- # print("5allbad", output)
- # self.assertTrue("Responses" in output, output)
- self.assertTrue("Replace" in output)
-
- def test_query_interactive_6all(self):
- from pyramid.scaffolds import copydir
-
- copydir.input_ = RawInputMockObject("all b")
- self._callFUT(
- self.src_fn,
- self.dest_fn,
- self.src_content,
- self.dest_content,
- simulate=False,
- out_=self.out,
- )
- output = self.out.getvalue()
- # The useful text in self.out gets wiped out on the second
- # call to raw_input, otherwise the test could be made
- # more usefully precise...
- # print("6all", output)
- # self.assertTrue("Responses" in output, output)
- self.assertTrue("Replace" in output)
-
-
-def dummy_template_renderer(content, v, filename=None):
- return content
diff --git a/tests/test_scaffolds/test_init.py b/tests/test_scaffolds/test_init.py
deleted file mode 100644
index 6238915f6..000000000
--- a/tests/test_scaffolds/test_init.py
+++ /dev/null
@@ -1,22 +0,0 @@
-import unittest
-
-
-class TestPyramidTemplate(unittest.TestCase):
- def _makeOne(self):
- from pyramid.scaffolds import PyramidTemplate
-
- return PyramidTemplate('name')
-
- def test_pre(self):
- inst = self._makeOne()
- vars = {'package': 'one'}
- inst.pre('command', 'output dir', vars)
- self.assertTrue(vars['random_string'])
- self.assertEqual(vars['package_logger'], 'one')
-
- def test_pre_root(self):
- inst = self._makeOne()
- vars = {'package': 'root'}
- inst.pre('command', 'output dir', vars)
- self.assertTrue(vars['random_string'])
- self.assertEqual(vars['package_logger'], 'app')
diff --git a/tests/test_scaffolds/test_template.py b/tests/test_scaffolds/test_template.py
deleted file mode 100644
index fc6b9f371..000000000
--- a/tests/test_scaffolds/test_template.py
+++ /dev/null
@@ -1,174 +0,0 @@
-import unittest
-
-from pyramid.compat import bytes_
-
-
-class TestTemplate(unittest.TestCase):
- def _makeOne(self, name='whatever'):
- from pyramid.scaffolds.template import Template
-
- return Template(name)
-
- def test_render_template_success(self):
- inst = self._makeOne()
- result = inst.render_template('{{a}} {{b}}', {'a': '1', 'b': '2'})
- self.assertEqual(result, bytes_('1 2'))
-
- def test_render_template_expr_failure(self):
- inst = self._makeOne()
- self.assertRaises(
- AttributeError,
- inst.render_template,
- '{{a.foo}}',
- {'a': '1', 'b': '2'},
- )
-
- def test_render_template_expr_success(self):
- inst = self._makeOne()
- result = inst.render_template('{{a.lower()}}', {'a': 'A'})
- self.assertEqual(result, b'a')
-
- def test_render_template_expr_success_via_pipe(self):
- inst = self._makeOne()
- result = inst.render_template('{{b|c|a.lower()}}', {'a': 'A'})
- self.assertEqual(result, b'a')
-
- def test_render_template_expr_success_via_pipe2(self):
- inst = self._makeOne()
- result = inst.render_template('{{b|a.lower()|c}}', {'a': 'A'})
- self.assertEqual(result, b'a')
-
- def test_render_template_expr_value_is_None(self):
- inst = self._makeOne()
- result = inst.render_template('{{a}}', {'a': None})
- self.assertEqual(result, b'')
-
- def test_render_template_with_escaped_double_braces(self):
- inst = self._makeOne()
- result = inst.render_template(
- '{{a}} {{b}} \\{\\{a\\}\\} \\{\\{c\\}\\}', {'a': '1', 'b': '2'}
- )
- self.assertEqual(result, bytes_('1 2 {{a}} {{c}}'))
-
- def test_render_template_with_breaking_escaped_braces(self):
- inst = self._makeOne()
- result = inst.render_template(
- '{{a}} {{b}} \\{\\{a\\} \\{b\\}\\}', {'a': '1', 'b': '2'}
- )
- self.assertEqual(result, bytes_('1 2 \\{\\{a\\} \\{b\\}\\}'))
-
- def test_render_template_with_escaped_single_braces(self):
- inst = self._makeOne()
- result = inst.render_template(
- '{{a}} {{b}} \\{a\\} \\{b', {'a': '1', 'b': '2'}
- )
- self.assertEqual(result, bytes_('1 2 \\{a\\} \\{b'))
-
- def test_module_dir(self):
- import sys
- import pkg_resources
-
- package = sys.modules['pyramid.scaffolds.template']
- path = pkg_resources.resource_filename(package.__name__, '')
- inst = self._makeOne()
- result = inst.module_dir()
- self.assertEqual(result, path)
-
- def test_template_dir__template_dir_is_None(self):
- inst = self._makeOne()
- self.assertRaises(AssertionError, inst.template_dir)
-
- def test_template_dir__template_dir_is_tuple(self):
- inst = self._makeOne()
- inst._template_dir = ('a', 'b')
- self.assertEqual(inst.template_dir(), ('a', 'b'))
-
- def test_template_dir__template_dir_is_not_None(self):
- import os
- import sys
- import pkg_resources
-
- package = sys.modules['pyramid.scaffolds.template']
- path = pkg_resources.resource_filename(package.__name__, '')
- inst = self._makeOne()
- inst._template_dir = 'foo'
- result = inst.template_dir()
- self.assertEqual(result, os.path.join(path, 'foo'))
-
- def test_write_files_path_exists(self):
- import os
- import sys
- import pkg_resources
-
- package = sys.modules['pyramid.scaffolds.template']
- path = pkg_resources.resource_filename(package.__name__, '')
- inst = self._makeOne()
- inst._template_dir = 'foo'
- inst.exists = lambda *arg: True
- copydir = DummyCopydir()
- inst.copydir = copydir
- command = DummyCommand()
- inst.write_files(command, 'output dir', {'a': 1})
- self.assertEqual(copydir.template_dir, os.path.join(path, 'foo'))
- self.assertEqual(copydir.output_dir, 'output dir')
- self.assertEqual(copydir.vars, {'a': 1})
- self.assertEqual(
- copydir.kw,
- {
- 'template_renderer': inst.render_template,
- 'indent': 1,
- 'verbosity': 1,
- 'simulate': False,
- 'overwrite': False,
- 'interactive': False,
- },
- )
-
- def test_write_files_path_missing(self):
- L = []
- inst = self._makeOne()
- inst._template_dir = 'foo'
- inst.exists = lambda *arg: False
- inst.out = lambda *arg: None
- inst.makedirs = lambda dir: L.append(dir)
- copydir = DummyCopydir()
- inst.copydir = copydir
- command = DummyCommand()
- inst.write_files(command, 'output dir', {'a': 1})
- self.assertEqual(L, ['output dir'])
-
- def test_run(self):
- L = []
- inst = self._makeOne()
- inst._template_dir = 'foo'
- inst.exists = lambda *arg: False
- inst.out = lambda *arg: None
- inst.makedirs = lambda dir: L.append(dir)
- copydir = DummyCopydir()
- inst.copydir = copydir
- command = DummyCommand()
- inst.run(command, 'output dir', {'a': 1})
- self.assertEqual(L, ['output dir'])
-
- def test_check_vars(self):
- inst = self._makeOne()
- self.assertRaises(RuntimeError, inst.check_vars, 'one', 'two')
-
-
-class DummyCopydir(object):
- def copy_dir(self, template_dir, output_dir, vars, **kw):
- self.template_dir = template_dir
- self.output_dir = output_dir
- self.vars = vars
- self.kw = kw
-
-
-class DummyArgs(object):
- simulate = False
- overwrite = False
- interactive = False
-
-
-class DummyCommand(object):
- args = DummyArgs()
- verbosity = 1
diff --git a/tests/test_scripts/test_pcreate.py b/tests/test_scripts/test_pcreate.py
deleted file mode 100644
index 6ac082b41..000000000
--- a/tests/test_scripts/test_pcreate.py
+++ /dev/null
@@ -1,409 +0,0 @@
-import unittest
-
-
-class TestPCreateCommand(unittest.TestCase):
- def setUp(self):
- from pyramid.compat import NativeIO
-
- self.out_ = NativeIO()
-
- def out(self, msg):
- self.out_.write(msg)
-
- def _getTargetClass(self):
- from pyramid.scripts.pcreate import PCreateCommand
-
- return PCreateCommand
-
- def _makeOne(self, *args, **kw):
- effargs = ['pcreate']
- effargs.extend(args)
- tgt_class = kw.pop('target_class', self._getTargetClass())
- cmd = tgt_class(effargs, **kw)
- cmd.out = self.out
- return cmd
-
- def test_run_show_scaffolds_exist(self):
- cmd = self._makeOne('-l')
- result = cmd.run()
- self.assertEqual(result, 0)
- out = self.out_.getvalue()
- self.assertTrue(out.count('Available scaffolds'))
-
- def test_run_show_scaffolds_none_exist(self):
- cmd = self._makeOne('-l')
- cmd.scaffolds = []
- result = cmd.run()
- self.assertEqual(result, 0)
- out = self.out_.getvalue()
- self.assertTrue(out.count('No scaffolds available'))
-
- def test_run_no_scaffold_no_args(self):
- cmd = self._makeOne(quiet=True)
- result = cmd.run()
- self.assertEqual(result, 2)
-
- def test_run_no_scaffold_name(self):
- cmd = self._makeOne('dummy')
- result = cmd.run()
- self.assertEqual(result, 2)
- out = self.out_.getvalue()
- self.assertTrue(
- out.count('You must provide at least one scaffold name')
- )
-
- def test_no_project_name(self):
- cmd = self._makeOne('-s', 'dummy')
- result = cmd.run()
- self.assertEqual(result, 2)
- out = self.out_.getvalue()
- self.assertTrue(out.count('You must provide a project name'))
-
- def test_unknown_scaffold_name(self):
- cmd = self._makeOne('-s', 'dummyXX', 'distro')
- result = cmd.run()
- self.assertEqual(result, 2)
- out = self.out_.getvalue()
- self.assertTrue(out.count('Unavailable scaffolds'))
-
- def test_known_scaffold_single_rendered(self):
- import os
-
- cmd = self._makeOne('-s', 'dummy', 'Distro')
- scaffold = DummyScaffold('dummy')
- cmd.scaffolds = [scaffold]
- cmd.pyramid_dist = DummyDist("0.1")
- result = cmd.run()
- self.assertEqual(result, 0)
- self.assertEqual(
- scaffold.output_dir,
- os.path.normpath(os.path.join(os.getcwd(), 'Distro')),
- )
- self.assertEqual(
- scaffold.vars,
- {
- 'project': 'Distro',
- 'egg': 'Distro',
- 'package': 'distro',
- 'pyramid_version': '0.1',
- 'pyramid_docs_branch': '0.1-branch',
- },
- )
-
- def test_scaffold_with_package_name(self):
- import os
-
- cmd = self._makeOne(
- '-s', 'dummy', '--package-name', 'dummy_package', 'Distro'
- )
- scaffold = DummyScaffold('dummy')
- cmd.scaffolds = [scaffold]
- cmd.pyramid_dist = DummyDist("0.1")
- result = cmd.run()
-
- self.assertEqual(result, 0)
- self.assertEqual(
- scaffold.output_dir,
- os.path.normpath(os.path.join(os.getcwd(), 'Distro')),
- )
- self.assertEqual(
- scaffold.vars,
- {
- 'project': 'Distro',
- 'egg': 'dummy_package',
- 'package': 'dummy_package',
- 'pyramid_version': '0.1',
- 'pyramid_docs_branch': '0.1-branch',
- },
- )
-
- def test_scaffold_with_hyphen_in_project_name(self):
- import os
-
- cmd = self._makeOne('-s', 'dummy', 'Distro-')
- scaffold = DummyScaffold('dummy')
- cmd.scaffolds = [scaffold]
- cmd.pyramid_dist = DummyDist("0.1")
- result = cmd.run()
- self.assertEqual(result, 0)
- self.assertEqual(
- scaffold.output_dir,
- os.path.normpath(os.path.join(os.getcwd(), 'Distro-')),
- )
- self.assertEqual(
- scaffold.vars,
- {
- 'project': 'Distro-',
- 'egg': 'Distro_',
- 'package': 'distro_',
- 'pyramid_version': '0.1',
- 'pyramid_docs_branch': '0.1-branch',
- },
- )
-
- def test_known_scaffold_absolute_path(self):
- import os
-
- path = os.path.abspath('Distro')
- cmd = self._makeOne('-s', 'dummy', path)
- cmd.pyramid_dist = DummyDist("0.1")
- scaffold = DummyScaffold('dummy')
- cmd.scaffolds = [scaffold]
- cmd.pyramid_dist = DummyDist("0.1")
- result = cmd.run()
- self.assertEqual(result, 0)
- self.assertEqual(
- scaffold.output_dir,
- os.path.normpath(os.path.join(os.getcwd(), 'Distro')),
- )
- self.assertEqual(
- scaffold.vars,
- {
- 'project': 'Distro',
- 'egg': 'Distro',
- 'package': 'distro',
- 'pyramid_version': '0.1',
- 'pyramid_docs_branch': '0.1-branch',
- },
- )
-
- def test_known_scaffold_multiple_rendered(self):
- import os
-
- cmd = self._makeOne('-s', 'dummy1', '-s', 'dummy2', 'Distro')
- scaffold1 = DummyScaffold('dummy1')
- scaffold2 = DummyScaffold('dummy2')
- cmd.scaffolds = [scaffold1, scaffold2]
- cmd.pyramid_dist = DummyDist("0.1")
- result = cmd.run()
- self.assertEqual(result, 0)
- self.assertEqual(
- scaffold1.output_dir,
- os.path.normpath(os.path.join(os.getcwd(), 'Distro')),
- )
- self.assertEqual(
- scaffold1.vars,
- {
- 'project': 'Distro',
- 'egg': 'Distro',
- 'package': 'distro',
- 'pyramid_version': '0.1',
- 'pyramid_docs_branch': '0.1-branch',
- },
- )
- self.assertEqual(
- scaffold2.output_dir,
- os.path.normpath(os.path.join(os.getcwd(), 'Distro')),
- )
- self.assertEqual(
- scaffold2.vars,
- {
- 'project': 'Distro',
- 'egg': 'Distro',
- 'package': 'distro',
- 'pyramid_version': '0.1',
- 'pyramid_docs_branch': '0.1-branch',
- },
- )
-
- def test_known_scaffold_with_path_as_project_target_rendered(self):
- import os
-
- cmd = self._makeOne('-s', 'dummy', '/tmp/foo/Distro/')
- scaffold = DummyScaffold('dummy')
- cmd.scaffolds = [scaffold]
- cmd.pyramid_dist = DummyDist("0.1")
- result = cmd.run()
- self.assertEqual(result, 0)
- self.assertEqual(
- scaffold.output_dir,
- os.path.normpath(os.path.join(os.getcwd(), '/tmp/foo/Distro')),
- )
- self.assertEqual(
- scaffold.vars,
- {
- 'project': 'Distro',
- 'egg': 'Distro',
- 'package': 'distro',
- 'pyramid_version': '0.1',
- 'pyramid_docs_branch': '0.1-branch',
- },
- )
-
- def test_scaffold_with_prod_pyramid_version(self):
- cmd = self._makeOne('-s', 'dummy', 'Distro')
- scaffold = DummyScaffold('dummy')
- cmd.scaffolds = [scaffold]
- cmd.pyramid_dist = DummyDist("0.2")
- result = cmd.run()
- self.assertEqual(result, 0)
- self.assertEqual(
- scaffold.vars,
- {
- 'project': 'Distro',
- 'egg': 'Distro',
- 'package': 'distro',
- 'pyramid_version': '0.2',
- 'pyramid_docs_branch': '0.2-branch',
- },
- )
-
- def test_scaffold_with_prod_pyramid_long_version(self):
- cmd = self._makeOne('-s', 'dummy', 'Distro')
- scaffold = DummyScaffold('dummy')
- cmd.scaffolds = [scaffold]
- cmd.pyramid_dist = DummyDist("0.2.1")
- result = cmd.run()
- self.assertEqual(result, 0)
- self.assertEqual(
- scaffold.vars,
- {
- 'project': 'Distro',
- 'egg': 'Distro',
- 'package': 'distro',
- 'pyramid_version': '0.2.1',
- 'pyramid_docs_branch': '0.2-branch',
- },
- )
-
- def test_scaffold_with_prod_pyramid_unparsable_version(self):
- cmd = self._makeOne('-s', 'dummy', 'Distro')
- scaffold = DummyScaffold('dummy')
- cmd.scaffolds = [scaffold]
- cmd.pyramid_dist = DummyDist("abc")
- result = cmd.run()
- self.assertEqual(result, 0)
- self.assertEqual(
- scaffold.vars,
- {
- 'project': 'Distro',
- 'egg': 'Distro',
- 'package': 'distro',
- 'pyramid_version': 'abc',
- 'pyramid_docs_branch': 'latest',
- },
- )
-
- def test_scaffold_with_dev_pyramid_version(self):
- cmd = self._makeOne('-s', 'dummy', 'Distro')
- scaffold = DummyScaffold('dummy')
- cmd.scaffolds = [scaffold]
- cmd.pyramid_dist = DummyDist("0.12dev")
- result = cmd.run()
- self.assertEqual(result, 0)
- self.assertEqual(
- scaffold.vars,
- {
- 'project': 'Distro',
- 'egg': 'Distro',
- 'package': 'distro',
- 'pyramid_version': '0.12dev',
- 'pyramid_docs_branch': 'master',
- },
- )
-
- def test_scaffold_with_dev_pyramid_long_version(self):
- cmd = self._makeOne('-s', 'dummy', 'Distro')
- scaffold = DummyScaffold('dummy')
- cmd.scaffolds = [scaffold]
- cmd.pyramid_dist = DummyDist("0.10.1dev")
- result = cmd.run()
- self.assertEqual(result, 0)
- self.assertEqual(
- scaffold.vars,
- {
- 'project': 'Distro',
- 'egg': 'Distro',
- 'package': 'distro',
- 'pyramid_version': '0.10.1dev',
- 'pyramid_docs_branch': 'master',
- },
- )
-
- def test_confirm_override_conflicting_name(self):
- from pyramid.scripts.pcreate import PCreateCommand
-
- class YahInputPCreateCommand(PCreateCommand):
- def confirm_bad_name(self, pkg_name):
- return True
-
- cmd = self._makeOne(
- '-s', 'dummy', 'Unittest', target_class=YahInputPCreateCommand
- )
- scaffold = DummyScaffold('dummy')
- cmd.scaffolds = [scaffold]
- cmd.pyramid_dist = DummyDist("0.10.1dev")
- result = cmd.run()
- self.assertEqual(result, 0)
- self.assertEqual(
- scaffold.vars,
- {
- 'project': 'Unittest',
- 'egg': 'Unittest',
- 'package': 'unittest',
- 'pyramid_version': '0.10.1dev',
- 'pyramid_docs_branch': 'master',
- },
- )
-
- def test_force_override_conflicting_name(self):
- cmd = self._makeOne(
- '-s', 'dummy', 'Unittest', '--ignore-conflicting-name'
- )
- scaffold = DummyScaffold('dummy')
- cmd.scaffolds = [scaffold]
- cmd.pyramid_dist = DummyDist("0.10.1dev")
- result = cmd.run()
- self.assertEqual(result, 0)
- self.assertEqual(
- scaffold.vars,
- {
- 'project': 'Unittest',
- 'egg': 'Unittest',
- 'package': 'unittest',
- 'pyramid_version': '0.10.1dev',
- 'pyramid_docs_branch': 'master',
- },
- )
-
- def test_force_override_site_name(self):
- from pyramid.scripts.pcreate import PCreateCommand
-
- class NayInputPCreateCommand(PCreateCommand):
- def confirm_bad_name(self, pkg_name):
- return False
-
- cmd = self._makeOne(
- '-s', 'dummy', 'Site', target_class=NayInputPCreateCommand
- )
- scaffold = DummyScaffold('dummy')
- cmd.scaffolds = [scaffold]
- cmd.pyramid_dist = DummyDist("0.10.1dev")
- result = cmd.run()
- self.assertEqual(result, 2)
-
-
-class Test_main(unittest.TestCase):
- def _callFUT(self, argv):
- from pyramid.scripts.pcreate import main
-
- return main(argv, quiet=True)
-
- def test_it(self):
- result = self._callFUT(['pcreate'])
- self.assertEqual(result, 2)
-
-
-class DummyScaffold(object):
- def __init__(self, name):
- self.name = name
-
- def run(self, command, output_dir, vars):
- self.command = command
- self.output_dir = output_dir
- self.vars = vars
-
-
-class DummyDist(object):
- def __init__(self, version):
- self.version = version