From 4a94b4cca6e609856cf717dfae5d7ea4a1df0469 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 23 Feb 2020 22:51:07 +0100 Subject: searx/testing.py: pylint & SPDX tag (no functional change) Signed-off-by: Markus Heiser --- searx/testing.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'searx/testing.py') diff --git a/searx/testing.py b/searx/testing.py index a3616dc12..8931c6a88 100644 --- a/searx/testing.py +++ b/searx/testing.py @@ -1,37 +1,38 @@ # -*- coding: utf-8 -*- +# SPDX-License-Identifier: AGPL-3.0-or-later """Shared testing code.""" +# pylint: disable=missing-function-docstring import os import subprocess import traceback -from os.path import dirname, join, abspath +from os.path import dirname, join, abspath, realpath from splinter import Browser from unittest2 import TestCase - class SearxTestLayer: """Base layer for non-robot tests.""" __name__ = u'SearxTestLayer' + @classmethod def setUp(cls): pass - setUp = classmethod(setUp) + @classmethod def tearDown(cls): pass - tearDown = classmethod(tearDown) + @classmethod def testSetUp(cls): pass - testSetUp = classmethod(testSetUp) + @classmethod def testTearDown(cls): pass - testTearDown = classmethod(testTearDown) class SearxRobotLayer(): @@ -41,10 +42,7 @@ class SearxRobotLayer(): os.setpgrp() # create new process group, become its leader # get program paths - webapp = os.path.join( - os.path.abspath(os.path.dirname(os.path.realpath(__file__))), - 'webapp.py' - ) + webapp = join(abspath(dirname(realpath(__file__))), 'webapp.py') exe = 'python' # set robot settings path @@ -105,7 +103,7 @@ if __name__ == '__main__': try: test_layer.setUp() run_robot_tests([getattr(robot, x) for x in dir(robot) if x.startswith('test_')]) - except Exception: + except Exception: # pylint: disable=broad-except errors = True print('Error occured: {0}'.format(traceback.format_exc())) test_layer.tearDown() -- cgit v1.2.3 From 81f106e5de58c40d5ee9dd3232ab2244ea4103cd Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 23 Feb 2020 23:03:05 +0100 Subject: searx/testing.py: bugfix process model (do not use Flask's debug mode) Don't enable Flask's debug mode, the debugger from Flask will cause a wired process model, where the server never dies. Further read: - debug mode: https://flask.palletsprojects.com/quickstart/#debug-mode - Flask.run(..): https://flask.palletsprojects.com/api/#flask.Flask.run closes: https://github.com/asciimoo/searx/issues/1862 Signed-off-by: Markus Heiser --- searx/testing.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'searx/testing.py') diff --git a/searx/testing.py b/searx/testing.py index 8931c6a88..716e203c1 100644 --- a/searx/testing.py +++ b/searx/testing.py @@ -45,8 +45,16 @@ class SearxRobotLayer(): webapp = join(abspath(dirname(realpath(__file__))), 'webapp.py') exe = 'python' + # The Flask app is started by Flask.run(...), don't enable Flask's debug + # mode, the debugger from Flask will cause wired process model, where + # the server never dies. Further read: + # + # - debug mode: https://flask.palletsprojects.com/quickstart/#debug-mode + # - Flask.run(..): https://flask.palletsprojects.com/api/#flask.Flask.run + + os.environ['SEARX_DEBUG'] = '0' + # set robot settings path - os.environ['SEARX_DEBUG'] = '1' os.environ['SEARX_SETTINGS_PATH'] = abspath( dirname(__file__) + '/settings_robot.yml') -- cgit v1.2.3 From aa95a0d70b57fe0dc0ba26b6511185e5629cbde2 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Mon, 24 Feb 2020 07:55:14 +0100 Subject: searx/testing.py: fixed pep8 error Signed-off-by: Markus Heiser --- searx/testing.py | 1 + 1 file changed, 1 insertion(+) (limited to 'searx/testing.py') diff --git a/searx/testing.py b/searx/testing.py index 716e203c1..f0e303e13 100644 --- a/searx/testing.py +++ b/searx/testing.py @@ -13,6 +13,7 @@ from os.path import dirname, join, abspath, realpath from splinter import Browser from unittest2 import TestCase + class SearxTestLayer: """Base layer for non-robot tests.""" -- cgit v1.2.3