/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

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