On Apr 18, 8:29 pm, Chris McDonough <[email protected]> wrote:
> On Wednesday, March 16, 2011 8:36:32 PM UTC-4, Shen, Yu-Teh wrote:
> > ----------------------------------------------------------------------
> > Traceback (most recent call last):
> >   File "/home/ytshen/proj/tests.py", line 104, in
> > > test_upload_forbidden
> > >     self.assertRaises(Forbidden, upload, context, request)
> > > AssertionError: Forbidden not raised
>
> Execution via the "router" (the WSGI application which represents the
> Pyramid application) is the easiest way to test ACLs.  Testing the way
> you've been doing it does not invoke any security wrappers (by design).

Thanks for the tip, Chris.  I managed to get it working last night
after looking at examples in pyramid.tests.test_router.py

import unittest
import webtest
from pyramid.exceptions import Forbidden
from myapp import main

app = webtest.TestApp(main({}, **{'sqlalchemy.url': 'sqlite://'}))

class Test(unittest.TestCase):

    def test(self):
        url = '/protected'
        # Make sure the view is not visible to the public
        self.assertRaises(Forbidden, app.get, url)

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to