[Zope3-Users] Calling a view in a doc test

2007-06-04 Thread Florian Lindner
Hello,
in a doctest I have an object which has a view registered.
I want to call this view and test for the XML it returns.
How can I call the view so that it is being rendered, just like called by a 
browser?

Thanks,

Florian
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Calling a view in a doc test

2007-06-04 Thread Jim Washington
Florian Lindner wrote:
 Hello,
 in a doctest I have an object which has a view registered.
 I want to call this view and test for the XML it returns.
 How can I call the view so that it is being rendered, just like called by a 
 browser?

 Thanks,

 Florian
 ___
 Zope3-users mailing list
 Zope3-users@zope.org
 http://mail.zope.org/mailman/listinfo/zope3-users
   
Hi, Florian

Search for zope.testbrowser.

It's sometimes used in functional doctests.

from zope.testbrowser.testing import Browser
browser = Browser('http://localhost/')
#browser.handleErrors = False
browser.open('/somepath/someview.html')

-Jim Washington
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] RE: Blog naming proposal

2007-06-04 Thread Mark, Jonathan (Integic)
A better name is Noiszzz 

Noize starts with a capital N, then a vowel, then a Z then another
vowel. It is too close to the word Nazi for some English speakers. 

I am not saying that people who like the name Noize also like Nazis. I
am just saying that the association will be there. Noiszzz is better
because the triple zzz is itself a noise.



___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] RE: Blog naming proposal

2007-06-04 Thread Martin Aspeli



Mark, Jonathan (Integic) wrote:
 
 A better name is Noiszzz 
 
 Noize starts with a capital N, then a vowel, then a Z then another
 vowel. It is too close to the word Nazi for some English speakers. 
 
 I am not saying that people who like the name Noize also like Nazis. I
 am just saying that the association will be there. Noiszzz is better
 because the triple zzz is itself a noise.
 

That's an even worse name ;-)

Noize sounds nothing like Nazi. I don't think the world is so sensitive that
we need to ban the letters N and z from the same word forever.

Martin
-- 
View this message in context: 
http://www.nabble.com/RE%3A-Blog-naming-proposal-tf3865792.html#a10952236
Sent from the Zope3 - users mailing list archive at Nabble.com.

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] Calling a view in a doc test

2007-06-04 Thread Marius Gedminas
On Mon, Jun 04, 2007 at 03:14:16PM +0200, Florian Lindner wrote:
 Hello,
 in a doctest I have an object which has a view registered.
 I want to call this view and test for the XML it returns.
 How can I call the view so that it is being rendered, just like called by a 
 browser?

Is that in a unit test, or a functional test?

In a unit test you can do it like this:

 context = ...yourcontentobject...
 from zope.publisher.browser import TestRequest
 request = TestRequest()
 view = MyViewClass(context, request)
 print view()
some xml or whatever output here

If you want to provide, e.g., form parameters, pass them to the request:

 request = TestRequest(form={'foo': u'Lalala\u1234'})

If your view does anything interesting (e.g. use TALES expressions, or
refer to other views like context/@@absolute_url), you will need to
register a whole bunch of components in your doctest setUp methods.
Don't forget to tear them down afterwards.  IIRC you will need

from zope.app.testing import setup

def setUp(test):
setup.placelessSetUp()
setup.setUpTraversal()

def tearDown(test):
setup.placelessTearDown()

at the very least.  Accessing other views, resources, or, god forbid,
forms, will require other component registrations.  At some point you
have two choices: figure out this stuff once and then use copy  paste
(actually, helper functions defined once in your project), or switch to
testing your views with functional tests.

Marius Gedminas
-- 
Cool. Does it also recode ISO10646-1 pcf files into the funny
permutations and subsets used a long time ago in a galaxy far far away
on the planets Isolatinus XV and Koiruski VIII ...
-- Markus Kuhn inquires about libXft


signature.asc
Description: Digital signature
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users