diff options
| author | Michael Merickel <michael@merickel.org> | 2020-01-03 23:14:26 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-03 23:14:26 -0600 |
| commit | 148cf5138638ce6b1b92b4e13fe1444df9451e34 (patch) | |
| tree | 7b088836b570b401caf510f130f144404cb19ca4 /docs/quick_tour | |
| parent | cc396692d82441f8142fb14041542ebd2dad6f0a (diff) | |
| parent | b349c2ba948148d2f5441308c6646f624100b364 (diff) | |
| download | pyramid-148cf5138638ce6b1b92b4e13fe1444df9451e34.tar.gz pyramid-148cf5138638ce6b1b92b4e13fe1444df9451e34.tar.bz2 pyramid-148cf5138638ce6b1b92b4e13fe1444df9451e34.zip | |
Merge pull request #3556 from stevepiercy/docs-synch-cookiecutter-pr-71
Update docs to sync with cookiecutter master branch
Diffstat (limited to 'docs/quick_tour')
38 files changed, 97 insertions, 46 deletions
diff --git a/docs/quick_tour/logging/.coveragerc b/docs/quick_tour/logging/.coveragerc index 128e26410..a94933b5f 100644 --- a/docs/quick_tour/logging/.coveragerc +++ b/docs/quick_tour/logging/.coveragerc @@ -1,3 +1,2 @@ [run] source = hello_world -omit = hello_world/test* diff --git a/docs/quick_tour/logging/MANIFEST.in b/docs/quick_tour/logging/MANIFEST.in index a75da6dad..7a73762f7 100644 --- a/docs/quick_tour/logging/MANIFEST.in +++ b/docs/quick_tour/logging/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include hello_world *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/quick_tour/logging/hello_world/views/default.py b/docs/quick_tour/logging/hello_world/views/default.py index bbb99d78c..4bbc01e11 100644 --- a/docs/quick_tour/logging/hello_world/views/default.py +++ b/docs/quick_tour/logging/hello_world/views/default.py @@ -3,7 +3,7 @@ from pyramid.view import view_config import logging log = logging.getLogger(__name__) -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='hello_world:templates/mytemplate.jinja2') def my_view(request): log.debug('Some Message') return {'project': 'hello_world'} diff --git a/docs/quick_tour/logging/hello_world/views/notfound.py b/docs/quick_tour/logging/hello_world/views/notfound.py index 69d6e2804..6d0ff4193 100644 --- a/docs/quick_tour/logging/hello_world/views/notfound.py +++ b/docs/quick_tour/logging/hello_world/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='hello_world:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} diff --git a/docs/quick_tour/logging/setup.py b/docs/quick_tour/logging/setup.py index e9c15db04..1fec15ce5 100644 --- a/docs/quick_tour/logging/setup.py +++ b/docs/quick_tour/logging/setup.py @@ -37,7 +37,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/quick_tour/logging/tests/__init__.py b/docs/quick_tour/logging/tests/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/docs/quick_tour/logging/tests/__init__.py diff --git a/docs/quick_tour/logging/hello_world/tests.py b/docs/quick_tour/logging/tests/test_it.py index f01ae2a3c..90c6302fe 100644 --- a/docs/quick_tour/logging/hello_world/tests.py +++ b/docs/quick_tour/logging/tests/test_it.py @@ -11,11 +11,17 @@ class ViewTests(unittest.TestCase): testing.tearDown() def test_my_view(self): - from .views.default import my_view + from hello_world.views.default import my_view request = testing.DummyRequest() info = my_view(request) self.assertEqual(info['project'], 'hello_world') + def test_notfound_view(self): + from hello_world.views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + class FunctionalTests(unittest.TestCase): def setUp(self): @@ -27,3 +33,7 @@ class FunctionalTests(unittest.TestCase): def test_root(self): res = self.testapp.get('/', status=200) self.assertTrue(b'Pyramid' in res.body) + + def test_notfound(self): + res = self.testapp.get('/badurl', status=404) + self.assertTrue(res.status_code == 404) diff --git a/docs/quick_tour/package/.coveragerc b/docs/quick_tour/package/.coveragerc index 128e26410..a94933b5f 100644 --- a/docs/quick_tour/package/.coveragerc +++ b/docs/quick_tour/package/.coveragerc @@ -1,3 +1,2 @@ [run] source = hello_world -omit = hello_world/test* diff --git a/docs/quick_tour/package/MANIFEST.in b/docs/quick_tour/package/MANIFEST.in index a75da6dad..7a73762f7 100644 --- a/docs/quick_tour/package/MANIFEST.in +++ b/docs/quick_tour/package/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include hello_world *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/quick_tour/package/hello_world/views/default.py b/docs/quick_tour/package/hello_world/views/default.py index 7458da006..000a66e2e 100644 --- a/docs/quick_tour/package/hello_world/views/default.py +++ b/docs/quick_tour/package/hello_world/views/default.py @@ -1,6 +1,6 @@ from pyramid.view import view_config -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='hello_world:templates/mytemplate.jinja2') def my_view(request): return {'project': 'hello_world'} diff --git a/docs/quick_tour/package/hello_world/views/notfound.py b/docs/quick_tour/package/hello_world/views/notfound.py index 69d6e2804..6d0ff4193 100644 --- a/docs/quick_tour/package/hello_world/views/notfound.py +++ b/docs/quick_tour/package/hello_world/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='hello_world:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} diff --git a/docs/quick_tour/package/setup.py b/docs/quick_tour/package/setup.py index e9c15db04..1fec15ce5 100644 --- a/docs/quick_tour/package/setup.py +++ b/docs/quick_tour/package/setup.py @@ -37,7 +37,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/quick_tour/package/tests/__init__.py b/docs/quick_tour/package/tests/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/docs/quick_tour/package/tests/__init__.py diff --git a/docs/quick_tour/package/hello_world/tests.py b/docs/quick_tour/package/tests/test_it.py index f01ae2a3c..90c6302fe 100644 --- a/docs/quick_tour/package/hello_world/tests.py +++ b/docs/quick_tour/package/tests/test_it.py @@ -11,11 +11,17 @@ class ViewTests(unittest.TestCase): testing.tearDown() def test_my_view(self): - from .views.default import my_view + from hello_world.views.default import my_view request = testing.DummyRequest() info = my_view(request) self.assertEqual(info['project'], 'hello_world') + def test_notfound_view(self): + from hello_world.views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + class FunctionalTests(unittest.TestCase): def setUp(self): @@ -27,3 +33,7 @@ class FunctionalTests(unittest.TestCase): def test_root(self): res = self.testapp.get('/', status=200) self.assertTrue(b'Pyramid' in res.body) + + def test_notfound(self): + res = self.testapp.get('/badurl', status=404) + self.assertTrue(res.status_code == 404) diff --git a/docs/quick_tour/sessions/.coveragerc b/docs/quick_tour/sessions/.coveragerc index 128e26410..a94933b5f 100644 --- a/docs/quick_tour/sessions/.coveragerc +++ b/docs/quick_tour/sessions/.coveragerc @@ -1,3 +1,2 @@ [run] source = hello_world -omit = hello_world/test* diff --git a/docs/quick_tour/sessions/MANIFEST.in b/docs/quick_tour/sessions/MANIFEST.in index a75da6dad..7a73762f7 100644 --- a/docs/quick_tour/sessions/MANIFEST.in +++ b/docs/quick_tour/sessions/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include hello_world *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/quick_tour/sessions/hello_world/views/default.py b/docs/quick_tour/sessions/hello_world/views/default.py index 33b8d8ded..52e002cf5 100644 --- a/docs/quick_tour/sessions/hello_world/views/default.py +++ b/docs/quick_tour/sessions/hello_world/views/default.py @@ -3,7 +3,7 @@ from pyramid.view import view_config import logging log = logging.getLogger(__name__) -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='hello_world:templates/mytemplate.jinja2') def my_view(request): log.debug('Some Message') session = request.session diff --git a/docs/quick_tour/sessions/hello_world/views/notfound.py b/docs/quick_tour/sessions/hello_world/views/notfound.py index 69d6e2804..6d0ff4193 100644 --- a/docs/quick_tour/sessions/hello_world/views/notfound.py +++ b/docs/quick_tour/sessions/hello_world/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='hello_world:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} diff --git a/docs/quick_tour/sessions/setup.py b/docs/quick_tour/sessions/setup.py index e9c15db04..1fec15ce5 100644 --- a/docs/quick_tour/sessions/setup.py +++ b/docs/quick_tour/sessions/setup.py @@ -37,7 +37,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/quick_tour/sessions/tests/__init__.py b/docs/quick_tour/sessions/tests/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/docs/quick_tour/sessions/tests/__init__.py diff --git a/docs/quick_tour/sessions/hello_world/tests.py b/docs/quick_tour/sessions/tests/test_it.py index f01ae2a3c..90c6302fe 100644 --- a/docs/quick_tour/sessions/hello_world/tests.py +++ b/docs/quick_tour/sessions/tests/test_it.py @@ -11,11 +11,17 @@ class ViewTests(unittest.TestCase): testing.tearDown() def test_my_view(self): - from .views.default import my_view + from hello_world.views.default import my_view request = testing.DummyRequest() info = my_view(request) self.assertEqual(info['project'], 'hello_world') + def test_notfound_view(self): + from hello_world.views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + class FunctionalTests(unittest.TestCase): def setUp(self): @@ -27,3 +33,7 @@ class FunctionalTests(unittest.TestCase): def test_root(self): res = self.testapp.get('/', status=200) self.assertTrue(b'Pyramid' in res.body) + + def test_notfound(self): + res = self.testapp.get('/badurl', status=404) + self.assertTrue(res.status_code == 404) diff --git a/docs/quick_tour/sqla_demo/.coveragerc b/docs/quick_tour/sqla_demo/.coveragerc index 918f8dea0..8b6a8026a 100644 --- a/docs/quick_tour/sqla_demo/.coveragerc +++ b/docs/quick_tour/sqla_demo/.coveragerc @@ -1,3 +1,2 @@ [run] source = sqla_demo -omit = sqla_demo/test* diff --git a/docs/quick_tour/sqla_demo/MANIFEST.in b/docs/quick_tour/sqla_demo/MANIFEST.in index e079655f9..13a26726d 100644 --- a/docs/quick_tour/sqla_demo/MANIFEST.in +++ b/docs/quick_tour/sqla_demo/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include sqla_demo *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/quick_tour/sqla_demo/development.ini b/docs/quick_tour/sqla_demo/development.ini index 056a672e4..a087e17a7 100644 --- a/docs/quick_tour/sqla_demo/development.ini +++ b/docs/quick_tour/sqla_demo/development.ini @@ -45,7 +45,7 @@ listen = localhost:6543 ### [loggers] -keys = root, sqla_demo, sqlalchemy +keys = root, sqla_demo, sqlalchemy, alembic [handlers] keys = console @@ -70,6 +70,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = INFO +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/quick_tour/sqla_demo/production.ini b/docs/quick_tour/sqla_demo/production.ini index fe7f946bd..ee588605d 100644 --- a/docs/quick_tour/sqla_demo/production.ini +++ b/docs/quick_tour/sqla_demo/production.ini @@ -39,7 +39,7 @@ listen = *:6543 ### [loggers] -keys = root, sqla_demo, sqlalchemy +keys = root, sqla_demo, sqlalchemy, alembic [handlers] keys = console @@ -64,6 +64,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = WARN +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/quick_tour/sqla_demo/pytest.ini b/docs/quick_tour/sqla_demo/pytest.ini index b4b690a0f..e7fd17682 100644 --- a/docs/quick_tour/sqla_demo/pytest.ini +++ b/docs/quick_tour/sqla_demo/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = sqla_demo -python_files = test*.py +addopts = --strict + +testpaths = + sqla_demo + tests diff --git a/docs/quick_tour/sqla_demo/setup.py b/docs/quick_tour/sqla_demo/setup.py index 28a8e0815..f3302a7e9 100644 --- a/docs/quick_tour/sqla_demo/setup.py +++ b/docs/quick_tour/sqla_demo/setup.py @@ -9,17 +9,17 @@ with open(os.path.join(here, 'CHANGES.txt')) as f: CHANGES = f.read() requires = [ - 'alembic', 'plaster_pastedeploy', - 'pyramid >= 1.9', - 'pyramid_debugtoolbar', + 'pyramid', 'pyramid_jinja2', + 'pyramid_debugtoolbar', + 'waitress', + 'alembic', 'pyramid_retry', 'pyramid_tm', 'SQLAlchemy', 'transaction', 'zope.sqlalchemy', - 'waitress', ] tests_require = [ @@ -43,7 +43,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ @@ -55,7 +55,7 @@ setup( 'main = sqla_demo:main', ], 'console_scripts': [ - 'initialize_sqla_demo_db = sqla_demo.scripts.initialize_db:main', + 'initialize_sqla_demo_db=sqla_demo.scripts.initialize_db:main', ], }, ) diff --git a/docs/quick_tour/sqla_demo/sqla_demo/__init__.py b/docs/quick_tour/sqla_demo/sqla_demo/__init__.py index 28bd1f80d..5c2ba5cc0 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/__init__.py +++ b/docs/quick_tour/sqla_demo/sqla_demo/__init__.py @@ -5,8 +5,8 @@ def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ with Configurator(settings=settings) as config: - config.include('pyramid_jinja2') config.include('.models') + config.include('pyramid_jinja2') config.include('.routes') config.scan() return config.make_wsgi_app() diff --git a/docs/quick_tour/sqla_demo/sqla_demo/alembic/script.py.mako b/docs/quick_tour/sqla_demo/sqla_demo/alembic/script.py.mako index 2c0156303..535780d13 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/alembic/script.py.mako +++ b/docs/quick_tour/sqla_demo/sqla_demo/alembic/script.py.mako @@ -15,10 +15,8 @@ down_revision = ${repr(down_revision)} branch_labels = ${repr(branch_labels)} depends_on = ${repr(depends_on)} - def upgrade(): ${upgrades if upgrades else "pass"} - def downgrade(): ${downgrades if downgrades else "pass"} diff --git a/docs/quick_tour/sqla_demo/sqla_demo/alembic/versions/README.txt b/docs/quick_tour/sqla_demo/sqla_demo/alembic/versions/README.txt index 09ed32c8d..b0d704d6a 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/alembic/versions/README.txt +++ b/docs/quick_tour/sqla_demo/sqla_demo/alembic/versions/README.txt @@ -1 +1 @@ -Placeholder for alembic versions
\ No newline at end of file +Placeholder for alembic versions diff --git a/docs/quick_tour/sqla_demo/sqla_demo/pshell.py b/docs/quick_tour/sqla_demo/sqla_demo/pshell.py index 108c04d5e..b0847ee90 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/pshell.py +++ b/docs/quick_tour/sqla_demo/sqla_demo/pshell.py @@ -1,5 +1,6 @@ from . import models + def setup(env): request = env['request'] diff --git a/docs/quick_tour/sqla_demo/sqla_demo/templates/404.jinja2 b/docs/quick_tour/sqla_demo/sqla_demo/templates/404.jinja2 index 1917f83c7..aaf12413f 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/templates/404.jinja2 +++ b/docs/quick_tour/sqla_demo/sqla_demo/templates/404.jinja2 @@ -2,7 +2,7 @@ {% block content %} <div class="content"> - <h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Alchemy scaffold</span></h1> + <h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Starter project</span></h1> <p class="lead"><span class="font-semi-bold">404</span> Page Not Found</p> </div> {% endblock content %} diff --git a/docs/quick_tour/sqla_demo/sqla_demo/templates/layout.jinja2 b/docs/quick_tour/sqla_demo/sqla_demo/templates/layout.jinja2 index 107691acf..82017688a 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/templates/layout.jinja2 +++ b/docs/quick_tour/sqla_demo/sqla_demo/templates/layout.jinja2 @@ -8,7 +8,7 @@ <meta name="author" content="Pylons Project"> <link rel="shortcut icon" href="{{request.static_url('sqla_demo:static/pyramid-16x16.png')}}"> - <title>Cookiecutter Alchemy project for the Pyramid Web Framework</title> + <title>Cookiecutter Starter project for the Pyramid Web Framework</title> <!-- Bootstrap core CSS --> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> diff --git a/docs/quick_tour/sqla_demo/sqla_demo/templates/mytemplate.jinja2 b/docs/quick_tour/sqla_demo/sqla_demo/templates/mytemplate.jinja2 index d8b0a4232..f2e7283f8 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/templates/mytemplate.jinja2 +++ b/docs/quick_tour/sqla_demo/sqla_demo/templates/mytemplate.jinja2 @@ -2,7 +2,7 @@ {% block content %} <div class="content"> - <h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Alchemy project</span></h1> + <h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Starter project</span></h1> <p class="lead">Welcome to <span class="font-normal">{{project}}</span>, a Pyramid application generated by<br><span class="font-normal">Cookiecutter</span>.</p> </div> -{% endblock content %}
\ No newline at end of file +{% endblock content %} diff --git a/docs/quick_tour/sqla_demo/sqla_demo/views/default.py b/docs/quick_tour/sqla_demo/sqla_demo/views/default.py index f7ad4c8f2..3aadb905f 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/views/default.py +++ b/docs/quick_tour/sqla_demo/sqla_demo/views/default.py @@ -1,12 +1,12 @@ -from pyramid.response import Response from pyramid.view import view_config +from pyramid.response import Response from sqlalchemy.exc import DBAPIError from .. import models -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='sqla_demo:templates/mytemplate.jinja2') def my_view(request): try: query = request.dbsession.query(models.MyModel) @@ -21,7 +21,7 @@ Pyramid is having a problem using your SQL database. The problem might be caused by one of the following things: 1. You may need to initialize your database tables with `alembic`. - Check your README.txt for description and try to run it. + Check your README.txt for descriptions and try to run it. 2. Your database server may not be running. Check that the database server referred to by the "sqlalchemy.url" setting in diff --git a/docs/quick_tour/sqla_demo/sqla_demo/views/notfound.py b/docs/quick_tour/sqla_demo/sqla_demo/views/notfound.py index 69d6e2804..3e088ab15 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/views/notfound.py +++ b/docs/quick_tour/sqla_demo/sqla_demo/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='sqla_demo:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} diff --git a/docs/quick_tour/sqla_demo/tests/__init__.py b/docs/quick_tour/sqla_demo/tests/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/docs/quick_tour/sqla_demo/tests/__init__.py diff --git a/docs/quick_tour/sqla_demo/sqla_demo/tests.py b/docs/quick_tour/sqla_demo/tests/test_it.py index 6db538ffd..c79e05022 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/tests.py +++ b/docs/quick_tour/sqla_demo/tests/test_it.py @@ -1,8 +1,9 @@ import unittest -import transaction from pyramid import testing +import transaction + def dummy_request(dbsession): return testing.DummyRequest(dbsession=dbsession) @@ -13,10 +14,10 @@ class BaseTest(unittest.TestCase): self.config = testing.setUp(settings={ 'sqlalchemy.url': 'sqlite:///:memory:' }) - self.config.include('.models') + self.config.include('sqla_demo.models') settings = self.config.get_settings() - from .models import ( + from sqla_demo.models import ( get_engine, get_session_factory, get_tm_session, @@ -28,11 +29,11 @@ class BaseTest(unittest.TestCase): self.session = get_tm_session(session_factory, transaction.manager) def init_database(self): - from .models.meta import Base + from sqla_demo.models.meta import Base Base.metadata.create_all(self.engine) def tearDown(self): - from .models.meta import Base + from sqla_demo.models.meta import Base testing.tearDown() transaction.abort() @@ -45,13 +46,13 @@ class TestMyViewSuccessCondition(BaseTest): super(TestMyViewSuccessCondition, self).setUp() self.init_database() - from .models import MyModel + from sqla_demo.models import MyModel model = MyModel(name='one', value=55) self.session.add(model) def test_passing_view(self): - from .views.default import my_view + from sqla_demo.views.default import my_view info = my_view(dummy_request(self.session)) self.assertEqual(info['one'].name, 'one') self.assertEqual(info['project'], 'sqla_demo') @@ -60,6 +61,6 @@ class TestMyViewSuccessCondition(BaseTest): class TestMyViewFailureCondition(BaseTest): def test_failing_view(self): - from .views.default import my_view + from sqla_demo.views.default import my_view info = my_view(dummy_request(self.session)) self.assertEqual(info.status_int, 500) |
