Browse Source

New way to run test via loader & conf

Yann Weber 8 years ago
parent
commit
a3b3102604
6 changed files with 18 additions and 6 deletions
  1. 11
    0
      install/loader.py
  2. 2
    0
      lodel/settings/validator.py
  3. 3
    1
      runtest
  4. 0
    4
      tests/__init__.py
  5. 1
    1
      tests/leapi/test_leobject.py
  6. 1
    0
      tests/tests_conf.d/lodel2.ini

+ 11
- 0
install/loader.py View File

@@ -7,6 +7,7 @@ import sys, os
7 7
 LODEL2_LIB_ABS_PATH = None
8 8
 if LODEL2_LIB_ABS_PATH is not None:
9 9
     sys.path.append(os.path.dirname(LODEL2_LIB_ABS_PATH))
10
+    sys.path.append(os.path.dirname(LODEL2_LIB_ABS_PATH))
10 11
 
11 12
 try:
12 13
     import lodel
@@ -36,6 +37,16 @@ def start():
36 37
 
37 38
 if __name__ == '__main__':
38 39
     start()
40
+
41
+    if Settings.runtest:
42
+        import unittest
43
+        import tests
44
+        loader = unittest.TestLoader()
45
+        suite = loader.discover('tests')
46
+        runner = unittest.TextTestRunner()
47
+        runner.run(suite)
48
+        exit()
49
+
39 50
     LodelHook.call_hook('lodel2_loader_main', '__main__', None)
40 51
     #Run interative python
41 52
     import code

+ 2
- 0
lodel/settings/validator.py View File

@@ -308,6 +308,8 @@ LODEL2_CONF_SPECS = {
308 308
                         SettingValidator('strip')),
309 309
         'lib_path': (   None,
310 310
                         SettingValidator('path')),
311
+        'runtest': (    True,
312
+                        SettingValidator('bool')),
311 313
     },
312 314
     'lodel2.logging.*' : {
313 315
         'level': (  'ERROR',

+ 3
- 1
runtest View File

@@ -53,6 +53,8 @@ cp -R examples $testdir
53 53
 cp -R tests $testdir
54 54
 cd $testdir
55 55
 rm -R conf.d && mv tests/tests_conf.d conf.d
56
-python3 -W ignore -m unittest $@
56
+make
57
+#python3 -W ignore -m unittest $@
58
+python3 loader.py
57 59
 
58 60
 rm -Rf $testdir

+ 0
- 4
tests/__init__.py View File

@@ -1,4 +0,0 @@
1
-try:
2
-    import loader
3
-except ImportError:
4
-    print("This tests are designed to be runned with the runtest utility")

+ 1
- 1
tests/leapi/test_leobject.py View File

@@ -3,7 +3,7 @@ from unittest import mock
3 3
 from unittest.mock import patch
4 4
 
5 5
 import tests.loader_utils
6
-from tests.leapi.query.utils import dyncode_module as dyncode
6
+import leapi_dyncode as dyncode
7 7
 
8 8
 from lodel.leapi.leobject import LeObject
9 9
 from lodel.leapi.query import LeDeleteQuery, LeUpdateQuery, LeGetQuery, \

+ 1
- 0
tests/tests_conf.d/lodel2.ini View File

@@ -3,6 +3,7 @@ debug = False
3 3
 sitename = noname
4 4
 plugins_path = /foo/plugins
5 5
 plugins = dummy, dummy_datasource
6
+runtest=True
6 7
 
7 8
 [lodel2.logging.stderr]
8 9
 level = Error

Loading…
Cancel
Save