소스 검색

add tests launcher

Bastien Sevajol 9 년 전
부모
커밋
23cbcc4ac8
1개의 변경된 파일26개의 추가작업 그리고 0개의 파일을 삭제
  1. 26 0
      tests.py

+ 26 - 0
tests.py 파일 보기

@@ -0,0 +1,26 @@
1
+import unittest
2
+
3
+"""
4
+python3.4 -m unittest /home/bux/Projets/socialintengine/intelligine/tests/simulation/mode/TestChangeMode.py && python3.4 -m unittest intelligine/tests/simulation/pheromone/TestDirection.py
5
+"""
6
+
7
+test_modules = [
8
+    'intelligine.tests.simulation.mode.TestChangeMode.TestChangeMode',
9
+    'intelligine.tests.simulation.pheromone.TestDirection.TestDirection',
10
+]
11
+
12
+suite = unittest.TestSuite()
13
+
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
+
24
+test_result = unittest.TextTestRunner().run(suite)
25
+if test_result.failures or test_result.errors:
26
+    exit(1)