summaryrefslogtreecommitdiff
path: root/searx/testing.py
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2017-05-15 14:23:23 +0200
committerGitHub <noreply@github.com>2017-05-15 14:23:23 +0200
commit4cffd78650c3f1dfce413ae0a1cd0453ebe6f277 (patch)
treeac65990c72156def2d49e81d981f0b3beda4fd2e /searx/testing.py
parent46a2c63f8e1c3819cceff2d61fe9106051e8ecee (diff)
parent52e615dede8538c36f569d2cf07835427a9a0db6 (diff)
downloadsearxng-4cffd78650c3f1dfce413ae0a1cd0453ebe6f277.tar.gz
searxng-4cffd78650c3f1dfce413ae0a1cd0453ebe6f277.zip
Merge pull request #913 from asciimoo/py3
Add Python3 compatibility
Diffstat (limited to 'searx/testing.py')
-rw-r--r--searx/testing.py42
1 files changed, 26 insertions, 16 deletions
diff --git a/searx/testing.py b/searx/testing.py
index 312e9f295..0d17b2a08 100644
--- a/searx/testing.py
+++ b/searx/testing.py
@@ -1,13 +1,16 @@
# -*- coding: utf-8 -*-
"""Shared testing code."""
-from plone.testing import Layer
-from unittest2 import TestCase
-from os.path import dirname, join, abspath
-
import os
import subprocess
+import traceback
+
+
+from os.path import dirname, join, abspath
+
+from splinter import Browser
+from unittest2 import TestCase
class SearxTestLayer:
@@ -32,7 +35,7 @@ class SearxTestLayer:
testTearDown = classmethod(testTearDown)
-class SearxRobotLayer(Layer):
+class SearxRobotLayer():
"""Searx Robot Test Layer"""
def setUp(self):
@@ -62,7 +65,12 @@ class SearxRobotLayer(Layer):
del os.environ['SEARX_SETTINGS_PATH']
-SEARXROBOTLAYER = SearxRobotLayer()
+# SEARXROBOTLAYER = SearxRobotLayer()
+def run_robot_tests(tests):
+ print('Running {0} tests'.format(len(tests)))
+ for test in tests:
+ with Browser() as browser:
+ test(browser)
class SearxTestCase(TestCase):
@@ -72,17 +80,19 @@ class SearxTestCase(TestCase):
if __name__ == '__main__':
- from tests.test_robot import test_suite
import sys
- from zope.testrunner.runner import Runner
+ # test cases
+ from tests import robot
base_dir = abspath(join(dirname(__file__), '../tests'))
if sys.argv[1] == 'robot':
- r = Runner(['--color',
- '--auto-progress',
- '--stop-on-error',
- '--path',
- base_dir],
- found_suites=[test_suite()])
- r.run()
- sys.exit(int(r.failed))
+ test_layer = SearxRobotLayer()
+ errors = False
+ try:
+ test_layer.setUp()
+ run_robot_tests([getattr(robot, x) for x in dir(robot) if x.startswith('test_')])
+ except Exception:
+ errors = True
+ print('Error occured: {0}'.format(traceback.format_exc()))
+ test_layer.tearDown()
+ sys.exit(1 if errors else 0)