Created
October 1, 2014 19:30
-
-
Save mcdonc/a317b66dd77df9d53ec4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# views.py | |
from pyramid.view import view_config | |
@view_config(route_name='home', renderer='templates/mytemplate.pt') | |
def my_view(request): | |
url = request.route_url('foo') | |
return {'project': 'myproj', 'url':url} | |
# tests.py | |
import unittest | |
from pyramid import testing | |
class ViewTests(unittest.TestCase): | |
def setUp(self): | |
self.config = testing.setUp() | |
self.config.add_route('foo', '/bar') | |
def tearDown(self): | |
testing.tearDown() | |
def test_my_view(self): | |
from .views import my_view | |
request = testing.DummyRequest() | |
info = my_view(request) | |
self.assertEqual(info['project'], 'myproj') | |
self.assertEqual(info['url'], 'http://example.com/bar') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment