Guest User

Untitled

a guest
Apr 25th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #!/usr/bin/env python
  2. """
  3. % python runtests.py <test files, ...>
  4. """
  5. import sys
  6. import imp
  7. import unittest
  8. from os.path import splitext, basename
  9.  
  10. def load_tests(filepath):
  11. suffixes = dict((s[0], s) for s in imp.get_suffixes())
  12. if splitext(filepath)[1] not in suffixes:
  13. return
  14.  
  15. name = basename(filepath).replace('.', '_')
  16. module = imp.load_source(name, filepath)
  17.  
  18. return unittest.defaultTestLoader.loadTestsFromModule(module)
  19.  
  20. if __name__ == '__main__':
  21. tests = unittest.TestSuite()
  22. for filepath in sys.argv[1:]:
  23. t = load_tests(filepath)
  24. if t is not None:
  25. tests.addTests(t)
  26. unittest.TextTestRunner().run(tests)
Add Comment
Please, Sign In to add comment