Marius, thanks for your answers, it was helpful :) Although I still have some silly problems with tests...
I've created simplest possible structure with view, content class and interface and a bit of zcml to register view as index.html. This works in Zope because after creating content object I'm able to go to index.html and see what I expected. I'm trying to create doctests and I'm not able to get my view with getMultiAdapter. I can't find why... Do I have to explicitly call XMLConfig or something like that? What is wrong? basic/basic.py: ------------------------ from persistent import Persistent from zope import schema from zope.interface import implements, Interface import zope.publisher.browser class IMyInterface(Interface): ''' interface ''' class MyContent(Persistent): #MyBaseContent): ''' content ''' implements(IMyInterface) class MyView(zope.publisher.browser.BrowserPage): ''' view ''' def __call__(self): return 'dddd' basic/configure.zcml ------------------------- <configure xmlns="http://namespaces.zope.org/zope" xmlns:zcml="http://namespaces.zope.org/zcml" xmlns:browser="http://namespaces.zope.org/browser"> <browser:page name="index.html" for=".basic.IMyInterface" class=".basic.MyView" permission="zope.Public" /> <browser:addMenuItem title="MyContent" class=".basic.MyContent" permission="zope.ManageContent" /> </configure> basic/tests/test_basic.py ------------------------------------------ import unittest from zope.app.testing import setup def setUp(test): setup.placelessSetUp() setup.setUpTraversal() def tearDown(test): setup.placelessTearDown() def test_basic(): """\ >>> from basic.basic import MyContent >>> from zope.publisher.browser import TestRequest >>> from zope import component >>> from zope.interface import Interface >>> test_content = MyContent() >>> request = TestRequest(form={'tfl.row_id':1}) >>> rview = component.getMultiAdapter( ... (test_content, request), Interface, 'index.html') >>> rview() 'a' """ def test_suite(): from zope.testing import doctest suite = unittest.TestSuite() suite.addTest(doctest.DocTestSuite( setUp=setUp, tearDown=tearDown, )) return suite if __name__=='__main__': unittest.main(defaultTest='test_suite') Another question is how to get request.principal? I did: >>> request = TestRequest(form={'tfl.row_id':1}) >>> class User(object): ... id = 'Jan' >>> request.setPrincipal(User()) but is this correct way? Shouldn't this be done by testing framework already? --- Maciej Wisniowski _______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users