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 | ## |
---|
22 | import unittest |
---|
23 | import doctest |
---|
24 | from waeup.sirp.utils import helpers |
---|
25 | |
---|
26 | from zope.interface import Interface, implements |
---|
27 | class IFakeObject(Interface): |
---|
28 | """Some marker interface.""" |
---|
29 | |
---|
30 | class FakeObject(object): |
---|
31 | implements(IFakeObject) |
---|
32 | |
---|
33 | class 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 | |
---|
43 | def 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 | |
---|
59 | if __name__ == '__main__': |
---|
60 | unittest.main(defaultTest='test_suite') |
---|