[Zope3-dev] Re: Deleting utilities in site management doesn't work correct

jürgen Kartnaller j.kartnaller at cable.vol.at
Sat Oct 8 04:12:51 EDT 2005


Thanks Tres,
I'll give it a try.

Jürgen

Tres Seaver wrote:
> jürgen Kartnaller wrote:
> 
>>>Hi Tres,
>>>I would really like to make a test for this but I have no idea how to start.
>>>
>>>It took me 10 minutes to fix the problem but I think it will take me 10
>>>hours to write the test.
>>>
>>>If you can point me to a starting direction or just give me an example
>>>test somewhere I will give it a try !
> 
> 
> Hmmm, the code in src/zope/app/component/browser has no tests at all.
> There is a 'xxx_tests' directory, which looks to have a bunch of
> now-invalid tests, moved aside by Stephan during servicegeddon.  I'll CC
> him just in case some of those tests were supposed to come back online.
> 
> For your bug, I would start by writing a doctest for the tools.py
> module, something like:
> 
>  1. Create a 'tests' subdirectory in the 'browser' directory, and
>     give it an empty '__init__.py'::
> 
>     $ mkdir src/zope/app/component/browser/tests
>     $ cat > src/zope/app/component/browser/tests/__init__.py
>     # Python package
>     ^D
> 
>  2. Add a 'tests/test_tools.py' module, with boilerplate to run
>     the doctests in 'tools.txt':
> 
>     $ cat > src/zope/app/component/browser/tests/test_tools.py
>     import unittest
>     from zope.testing import doctest
>     from zope.app.testing.placelesssetup import setUp
>     from zope.app.testing.placelesssetup import tearDown
> 
>     def test_suite():
>         return unittest.TestSuite((
>         doctest.DocFileSuite('../tools.txt',
>                              setUp=setUp,
>                              tearDown=tearDown),
>         ))
> 
>     if __name__ == "__main__":
>         unittest.main(defaultTest='test_suite')
>     ^D
> 
>  3. Start writing 'tools.txt', documenting the behavior of the
>     methods of the SiteManagementView class.  You could write only
>     a test for 'delete' first, which should fail until you apply
>     your patch.  Look at 'src/zope/app/component/adapterregistry.txt'
>     for an example doctest file.
> 
>     $ vim src/zope/app/component/browser/tools.txt
> 
>  4. Run the tests, iteratively, during development:
> 
>     $ python test.py -u zope.app.component.browser
> 
>  5. Check in the new tools.txt and tests/ directory:
> 
>     $ svn add src/zope/app/component/browser/tools.txt
>     $ svn add src/zope/app/component/browser/tests
>     $ svn commit -m "Ensure that SiteManagerView.delete doesn't\
>     bite it's own tail."
> 
> 
> Hope that helps,
> 
> 
> Tres.
> --
> ===================================================================
> Tres Seaver          +1 202-558-7113          tseaver at palladion.com
> Palladion Software   "Excellence by Design"    http://palladion.com



More information about the Zope3-dev mailing list