tests.py 1.0KB

123456789101112131415161718192021222324252627282930
  1. import unittest
  2. from os import getcwd
  3. from sys import path as ppath
  4. ppath.insert(1,getcwd()+'/modules') # TODO: win32 compatibilite (python path)
  5. """
  6. python3.4 -m unittest /home/bux/Projets/socialintengine/intelligine/tests/simulation/mode/TestChangeMode.py && python3.4 -m unittest intelligine/tests/simulation/pheromone/TestDirection.py
  7. """
  8. test_modules = [
  9. 'intelligine.tests.simulation.mode.TestChangeMode.TestChangeMode',
  10. 'intelligine.tests.simulation.pheromone.TestDirection.TestDirection',
  11. ]
  12. suite = unittest.TestSuite()
  13. for t in test_modules:
  14. try:
  15. # If the module defines a suite() function, call it to get the suite.
  16. mod = __import__(t, globals(), locals(), ['suite'])
  17. suitefn = getattr(mod, 'suite')
  18. suite.addTest(suitefn())
  19. except (ImportError, AttributeError):
  20. # else, just load all the test cases from the module.
  21. suite.addTest(unittest.defaultTestLoader.loadTestsFromName(t))
  22. test_result = unittest.TextTestRunner().run(suite)
  23. if test_result.failures or test_result.errors:
  24. exit(1)