PageRenderTime 29ms CodeModel.GetById 21ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/unit_tests/test_plugin_interfaces.py

https://bitbucket.org/jpellerin/nose/
Python | 45 lines | 33 code | 12 blank | 0 comment | 13 complexity | a2a6d506588e1939166d747a41f5d734 MD5 | raw file
 1import unittest
 2from nose.plugins.base import IPluginInterface
 3
 4class 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            
44if __name__ == '__main__':
45    unittest.main()