/unit_tests/test_plugin_interfaces.py
https://bitbucket.org/jpellerin/nose/ · Python · 45 lines · 33 code · 12 blank · 0 comment · 10 complexity · a2a6d506588e1939166d747a41f5d734 MD5 · raw file
- 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()