I am running into something weird. I have a unittest that looks like this:
def test_configure_default_authentication_policy(self):
from pyramid.interfaces import IAuthenticationPolicy
from pyramid.authentication import AuthTktAuthenticationPolicy
factory = self.ApplicationFactory()
config = factory.configure(factory.default_settings)
policy = config.registry.queryUtility(IAuthenticationPolicy)
self.assertTrue(isinstance(policy, AuthTktAuthenticationPolicy))
self.assertEqual(policy.cookie.http_only, True)
This is testing part of a factory class that is responsible for creating
the WSGI app. That particular configure method looks like this:
def configure(self, settings):
"""Build the pyramid application configuration.
:param dict settings: application settings
:rtype: :py:class:`pyramid.config.Configurator`
"""
authentication_policy = AuthTktAuthenticationPolicy(
settings['authentication.secret'],
cookie_name=settings['authentication.cookie'],
include_ip=settings['authentication.include_ip'],
max_age=settings['authentication.lifetime'],
timeout=settings['authentication.lifetime'],
reissue_time=settings['authentication.reissue_time'],
http_only=True,
wild_domain=False)
config = Configurator(
settings=settings,
authentication_policy=authentication_policy)
config.set_renderer_globals_factory(GlobalsFactory)
config.add_route('siteroot', '/')
return config
this test passes. I also have a browser test that tries the not-found
exception view:
class FunctionalTestCase(unittest.TestCase):
def setUp(self):
from voipro.portal.run import main
from infrae.testbrowser.browser import Browser
self.app = main({})
self.browser = Browser(self.app)
class NotFoundFunctionalTests(FunctionalTestCase):
def test_invoked(self):
self.browser.open('http://localhost/not-found')
self.assertEqual(self.browser.status_code, 404)
self.assertTrue('The page you tried to access does not exist'
in self.browser.contents)
this test also passes fine when run in isolation. However when I run all
tests the browser test fails: when the exception view is rendered the
globals factory is not called. It looks like there is some leakage from
test_configure_default_authentication_policy, but I don't see why.
Wichert.
--
You received this message because you are subscribed to the Google Groups
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/pylons-devel?hl=en.