[Product-Developers] Need help writing tests

hannesc hannes at opennetworks.co.za
Mon Oct 27 11:27:01 UTC 2008


I have been going through Martin Aspeli's book "Professional Plone
Development" and I am having a lot of trouble with the tests. I have done
everything too the letter up until page 73. The problem now is that when I
run the test, I get the following error:

Module: optilux.policy.tests

AttributeError: 'module' object has no attribute 'test_suite'


Module: optilux.policy.tests.test_setup

NameError: global name 'untitest' is not defined

The __init__.py file looks as follows:

from Products.Five import zcml
from Products.Five import fiveconfigure
from Testing import ZopeTestCase as ztc
from Products.PloneTestCase import PloneTestCase as ptc
from Products.PloneTestCase.layer import onsetup
@onsetup
def setup_optilux_policy():
    """Set up the additional products required for the Optilux site policy
    
    The @onsetup decorator causes the execution of this body to be deffered
    until the setup of the Plone site testing layer."""
    
    # Load the ZCML configuration for the optilux.policy package.
    
    fiveconfigure.debug_mode = True
    import optilux.policy
    zcml.load_config('configure.zcml', optilux.policy)
    fiveconfigure.debug_mode = False
    
    # We need to tell the testing framework that these products should be
    # available. This can't happen until after we have loaded the ZCML.
    
    ztc.installPackage('optilux.policy')
    
# The order here is important: We first call the (deferred) function which
# installs the products we need for the Optilux package. Then, we let
# PloneTestCase set up this product on installation.
setup_optilux_policy()
ptc.setupPloneSite(products=['optilux.policy'])
class OptiluxPolicyTestCase(ptc.PloneTestCase):
    """We use this base class for all the tests in this package. If
necessary,
    we can put common utility or setup code in here."""

The test_setup.py looks as follows:

import unittest
from optilux.policy.tests.base import OptiluxPolicyTestCase
class TestSetup(OptiluxPolicyTestCase):
    
    def test_portal_title(self):
        self.assertEquals("Optilux Cinemas",
self.portal.getProperty('title'))
        
    def test_portal_description(self):
        self.assertEquals("Welcome to Optilux Cinemas",
self.portal.getProperty('description'))
        
def test_suite():
    suite = unittest.TestSuite()
    suite.addTest(untitest.makeSuite(TestSetup))
    return suite

Please help. :( I have absolutely no idea what is going wrong.
-- 
View this message in context: http://n2.nabble.com/Need-help-writing-tests-tp1381925p1381925.html
Sent from the Product Developers mailing list archive at Nabble.com.





More information about the Product-Developers mailing list