File: test_plugin_interfaces.py

package info (click to toggle)
nose 0.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,208 kB
  • ctags: 2,517
  • sloc: python: 13,200; makefile: 80; sh: 2
file content (45 lines) | stat: -rw-r--r-- 1,410 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import unittest
from nose.plugins.base import IPluginInterface

class TestPluginInterfaces(unittest.TestCase):

    def test_api_methods_present(self):

        from nose.loader import TestLoader
        from nose.selector import Selector

        
        exclude = [ 'loadTestsFromGenerator',
                    'loadTestsFromGeneratorMethod'
                    ]
        
        selfuncs = [ f for f in dir(Selector)
                     if f.startswith('want') ]
        loadfuncs = [ f for f in dir(TestLoader)
                      if f.startswith('load') and not f in exclude ]
        
        others = ['addDeprecated', 'addError', 'addFailure',
                  'addSkip', 'addSuccess', 'startTest', 'stopTest',
                  'prepareTest', 'begin', 'report'
                  ] 

        expect = selfuncs + loadfuncs + others
        
        pd = dir(IPluginInterface)
        
        for f in expect:
            assert f in pd, "No %s in IPluginInterface" % f
            assert getattr(IPluginInterface, f).__doc__, \
                "No docs for %f in IPluginInterface" % f
            
    def test_no_instantiate(self):
        try:
            p = IPluginInterface()
        except TypeError:
            pass
        else:
            assert False, \
                "Should not be able to instantiate IPluginInterface"
            
if __name__ == '__main__':
    unittest.main()