Browse Source

[fix] robot tests and pep8 check

Adam Tauber 9 years ago
parent
commit
39d2e0427f
3 changed files with 20 additions and 6 deletions
  1. 1
    0
      .gitignore
  2. 2
    3
      manage.sh
  3. 17
    3
      searx/testing.py

+ 1
- 0
.gitignore View File

5
 robot_log.html
5
 robot_log.html
6
 robot_output.xml
6
 robot_output.xml
7
 robot_report.html
7
 robot_report.html
8
+test_basic/
8
 setup.cfg
9
 setup.cfg
9
 
10
 
10
 *.pyc
11
 *.pyc

+ 2
- 3
manage.sh View File

15
 
15
 
16
 pep8_check() {
16
 pep8_check() {
17
     echo '[!] Running pep8 check'
17
     echo '[!] Running pep8 check'
18
-    pep8 "$SEARX_DIR" "$BASE_DIR/tests"
18
+    pep8 --max-line-length=120 "$SEARX_DIR" "$BASE_DIR/tests"
19
 }
19
 }
20
 
20
 
21
 unit_tests() {
21
 unit_tests() {
32
 
32
 
33
 robot_tests() {
33
 robot_tests() {
34
     echo '[!] Running robot tests'
34
     echo '[!] Running robot tests'
35
-    python -c "import zope.testrunner; import sys; sys.exit(zope.testrunner.run("\
36
-"['--color', '--auto-progress', '--layer', 'SearxRobotLayer', '--test-path', '$BASE_DIR']))"
35
+    PYTHONPATH=`pwd` python "$SEARX_DIR/testing.py" robot
37
 }
36
 }
38
 
37
 
39
 tests() {
38
 tests() {

+ 17
- 3
searx/testing.py View File

3
 
3
 
4
 from plone.testing import Layer
4
 from plone.testing import Layer
5
 from unittest2 import TestCase
5
 from unittest2 import TestCase
6
+from os.path import dirname, join, abspath
6
 
7
 
7
 
8
 
8
 import os
9
 import os
42
             os.path.abspath(os.path.dirname(os.path.realpath(__file__))),
43
             os.path.abspath(os.path.dirname(os.path.realpath(__file__))),
43
             'webapp.py'
44
             'webapp.py'
44
         )
45
         )
45
-        exe = os.path.abspath(os.path.dirname(__file__) + '/../bin/py')
46
+        exe = 'python'
46
 
47
 
47
         # set robot settings path
48
         # set robot settings path
48
-        os.environ['SEARX_SETTINGS_PATH'] = os.path.abspath(
49
-            os.path.dirname(__file__) + '/settings_robot.yml')
49
+        os.environ['SEARX_SETTINGS_PATH'] = abspath(
50
+            dirname(__file__) + '/settings_robot.yml')
50
 
51
 
51
         # run the server
52
         # run the server
52
         self.server = subprocess.Popen(
53
         self.server = subprocess.Popen(
68
     """Base test case for non-robot tests."""
69
     """Base test case for non-robot tests."""
69
 
70
 
70
     layer = SearxTestLayer
71
     layer = SearxTestLayer
72
+
73
+
74
+if __name__ == '__main__':
75
+    from tests.test_robot import test_suite
76
+    import sys
77
+    from zope.testrunner.runner import Runner
78
+
79
+    base_dir = abspath(join(dirname(__file__), '../tests'))
80
+    if sys.argv[1] == 'robot':
81
+        Runner(['--color',
82
+                '--auto-progress',
83
+                '--path', base_dir],
84
+               found_suites=[test_suite()]).run()