tests.py 1.1KB

12345678910111213141516171819202122232425262728293031
  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/molecule/TestDirection.py
  7. """
  8. test_modules = [
  9. 'intelligine.tests.simulation.mode.TestChangeMode.TestChangeMode',
  10. 'intelligine.tests.simulation.molecule.TestDirection.TestDirection',
  11. 'intelligine.tests.simulation.bypass.TestByPass.TestByPass',
  12. ]
  13. suite = unittest.TestSuite()
  14. for t in test_modules:
  15. try:
  16. # If the module defines a suite() function, call it to get the suite.
  17. mod = __import__(t, globals(), locals(), ['suite'])
  18. suitefn = getattr(mod, 'suite')
  19. suite.addTest(suitefn())
  20. except (ImportError, AttributeError):
  21. # else, just load all the test cases from the module.
  22. suite.addTest(unittest.defaultTestLoader.loadTestsFromName(t))
  23. test_result = unittest.TextTestRunner().run(suite)
  24. if test_result.failures or test_result.errors:
  25. exit(1)