-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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          [EMAIL PROTECTED]
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDRrQU+gerLs4ltQ4RAiqgAJ92CMhb4xXbKwBecyHWITI0cd7v6QCgtWUW
pLrEv+UXgRcioeQvU6r7UI8=
=lfM7
-----END PGP SIGNATURE-----

_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to