source: main/waeup.sirp/trunk/src/waeup/sirp/utils/tests/test_helpers.py @ 5736

Last change on this file since 5736 was 5735, checked in by uli, 14 years ago

Add unittest for factory base. In the unittest we check for things not
very important to developers. The important bits are explained and
tested in the docstring of the class. The unittest helps us also to
please the test coverage detector.

File size: 2.0 KB
Line 
1##
2## test_helpers.py
3## Login : <uli@pu.smp.net>
4## Started on  Sat Feb 12 14:39:42 2011 Uli Fouquet
5## $Id$
6##
7## Copyright (C) 2011 Uli Fouquet
8## This program is free software; you can redistribute it and/or modify
9## it under the terms of the GNU General Public License as published by
10## the Free Software Foundation; either version 2 of the License, or
11## (at your option) any later version.
12##
13## This program is distributed in the hope that it will be useful,
14## but WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16## GNU General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with this program; if not, write to the Free Software
20## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21##
22import unittest
23import doctest
24from waeup.sirp.utils import helpers
25
26from zope.interface import Interface, implements
27class IFakeObject(Interface):
28    """Some marker interface."""
29
30class FakeObject(object):
31    implements(IFakeObject)
32
33class FactoryBaseTestCase(unittest.TestCase):
34
35    def test_ifaces(self):
36        # We test all relevant parts in the docstring. But the interfaces
37        # method has to be tested to please the coverage report as well.
38        factory = helpers.FactoryBase()
39        factory.factory = FakeObject
40        self.assertTrue(factory.getInterfaces()(IFakeObject))
41        return
42       
43def test_suite():
44    suite = unittest.TestSuite()
45    # Register local test cases...
46    for testcase in [FactoryBaseTestCase, ]:
47        suite.addTests(
48            unittest.TestLoader().loadTestsFromTestCase(testcase)
49            )
50    # Add tests from docstrings in helpers.py...
51    suite.addTests(
52        doctest.DocTestSuite(
53            helpers,
54            optionflags = doctest.ELLIPSIS + doctest.REPORT_NDIFF,
55            )
56        )
57    return suite
58
59if __name__ == '__main__':
60    unittest.main(defaultTest='test_suite')
Note: See TracBrowser for help on using the repository browser.