I'm not sure which version of bfg you're contrasting this against, but if the view is a class, constructing the class just constructs the class. It's not until the class' __call__ is invoked that a response is potentially generated. If a previous BFG version worked differently, it was a bug.
In general, when you're testing code in BFG 1.1+, test the code as it appears in your editor buffer without taking any bfg_view decorators into account. bfg_view decorators don't actually influence the behavior of the code in 1.1+, so you need to test the code "literally". In the case of a class-based view, this means constructing the class with a context and a request, then invoking its __call__ method. - C Andreas Jung wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Running the zopyx.smartprintng.server tests with Repoze 1.2a9: > > Calling the index() view no longer returns a response object with > a status attribute: > > > /data/develop/repository/svn.zope.org/zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/tests.py(96)test_index() > - -> self.assertEqual(result.status, '200 OK') > (Pdb) list > 91 def test_index(self): > 92 from zopyx.smartprintng.server.views import index > 93 context = Server() > 94 request = testing.DummyRequest() > 95 result = index(context, request) > 96 -> self.assertEqual(result.status, '200 OK') > 97 body = result.app_iter[0] > 98 self.assertEqual(len(result.headerlist), 2) > 99 self.assertEqual(result.headerlist[0], > 100 ('Content-Type', 'text/html; > charset=UTF-8')) > 101 self.assertEqual(result.headerlist[1], ('Content-Length', > (Pdb) print result > <zopyx.smartprintng.server.views.index object at 0x1c57590> > > So 'result' is now the view class itself? > > > 36 @bfg_view(for_=Server, request_method='GET', permission='read') > 37 class index(object): > 38 """ The default view providing some system information """ > 39 > 40 def __init__(self, context, request): > 41 self.context = context > 42 self.request = request > 43 > 44 def __call__(self): > 45 converters = self.context.availableConverters() > 46 version = > pkg_resources.require('zopyx.smartprintng.server')[0].versionĀ· > 47 return render_template_to_response('templates/index.pt', > 48 context=self.context, > 49 converters=converters, > 50 request=self.request, > 51 version=version, > 52 > project='zopyx.smartprintng.server') > > Andreas > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.10 (Darwin) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iEYEARECAAYFAks/f9gACgkQCJIWIbr9KYxEpACfWsrY42pivfgSJJX5d0GtL8fC > dWgAoJu2McNlFv7BlTmDC4hz9oWttwTA > =Cibm > -----END PGP SIGNATURE----- > > > _______________________________________________ > Repoze-dev mailing list > Repoze-dev@lists.repoze.org > http://lists.repoze.org/listinfo/repoze-dev _______________________________________________ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev