[Zope-CMF] Setting up a dummy vocabulary for a doctest

Charlie Clark charlie.clark at clark-consulting.eu
Sat Sep 18 13:23:40 EDT 2010


Hi,

I'm writing tests for my replacement views. In the preferences form I use  
a vocabulary to list the possible skin choices. For testing the forms I'm  
generally using doctests to check the rendered HTML but I haven't been  
able to work out how to add get a dummy vocabulary to work with the test  
although it is correctly registered. This is from my doctest:

Set up dummy skins vocabulary
     >>> from zope.schema.interfaces import IVocabularyFactory
     >>> from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
     >>> terms = [SimpleTerm('default', 'default', 'default'),  
SimpleTerm('fancy', 'fancy', 'fancy')]
     >>> vocab = lambda: SimpleVocabulary(terms)
     >>> from zope.component import getSiteManager
     >>> sm = getSiteManager()
     >>> sm.registerUtility(vocab, IVocabularyFactory, u'cmf.portal_skins')

But as soon as I call the preferences form I get (after logging in)

>> browser.open("http://localhost/site/@@preferences.html")

Error Value:\n unknown vocabulary: u\'cmf.portal_skins\'

Any ideas?

I've commited the doctest with the failing issues commented out.

Charlie
-- 
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Helmholtzstr. 20
Düsseldorf
D- 40215
Tel: +49-211-600-3657
Mobile: +49-178-782-6226


More information about the Zope-CMF mailing list