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
 LODEL2_LIB_ABS_PATH = None
7
 LODEL2_LIB_ABS_PATH = None
8
 if LODEL2_LIB_ABS_PATH is not None:
8
 if LODEL2_LIB_ABS_PATH is not None:
9
     sys.path.append(os.path.dirname(LODEL2_LIB_ABS_PATH))
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
 try:
12
 try:
12
     import lodel
13
     import lodel
36
 
37
 
37
 if __name__ == '__main__':
38
 if __name__ == '__main__':
38
     start()
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
     LodelHook.call_hook('lodel2_loader_main', '__main__', None)
50
     LodelHook.call_hook('lodel2_loader_main', '__main__', None)
40
     #Run interative python
51
     #Run interative python
41
     import code
52
     import code

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

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

+ 3
- 1
runtest View File

53
 cp -R tests $testdir
53
 cp -R tests $testdir
54
 cd $testdir
54
 cd $testdir
55
 rm -R conf.d && mv tests/tests_conf.d conf.d
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
 rm -Rf $testdir
60
 rm -Rf $testdir

+ 0
- 4
tests/__init__.py View File

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
 from unittest.mock import patch
3
 from unittest.mock import patch
4
 
4
 
5
 import tests.loader_utils
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
 from lodel.leapi.leobject import LeObject
8
 from lodel.leapi.leobject import LeObject
9
 from lodel.leapi.query import LeDeleteQuery, LeUpdateQuery, LeGetQuery, \
9
 from lodel.leapi.query import LeDeleteQuery, LeUpdateQuery, LeGetQuery, \

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

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

Loading…
Cancel
Save