Imported Upstream version 1.1.2
[platform/upstream/python-nose.git] / unit_tests / test_plugin_interfaces.py
1 import unittest
2 from nose.plugins.base import IPluginInterface
3
4 class TestPluginInterfaces(unittest.TestCase):
5
6     def test_api_methods_present(self):
7
8         from nose.loader import TestLoader
9         from nose.selector import Selector
10
11         
12         exclude = [ 'loadTestsFromGenerator',
13                     'loadTestsFromGeneratorMethod'
14                     ]
15         
16         selfuncs = [ f for f in dir(Selector)
17                      if f.startswith('want') ]
18         loadfuncs = [ f for f in dir(TestLoader)
19                       if f.startswith('load') and not f in exclude ]
20         
21         others = ['addDeprecated', 'addError', 'addFailure',
22                   'addSkip', 'addSuccess', 'startTest', 'stopTest',
23                   'prepareTest', 'begin', 'report'
24                   ] 
25
26         expect = selfuncs + loadfuncs + others
27         
28         pd = dir(IPluginInterface)
29         
30         for f in expect:
31             assert f in pd, "No %s in IPluginInterface" % f
32             assert getattr(IPluginInterface, f).__doc__, \
33                 "No docs for %f in IPluginInterface" % f
34             
35     def test_no_instantiate(self):
36         try:
37             p = IPluginInterface()
38         except TypeError:
39             pass
40         else:
41             assert False, \
42                 "Should not be able to instantiate IPluginInterface"
43             
44 if __name__ == '__main__':
45     unittest.main()