1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-15 09:10:12 +01:00
searxng/tests/unit
Markus Heiser d80fcbc635 [fix] unit test_xpath.py: name 'logger' is not defined
Depending on the order in which the unit tests are executed, the python modules
of the engines are initialized (monkey patched) or not. As the order of the
tests is not static, random errors may occur.

To avaoid random `NameError: name 'logger' is not defined` in the unit tests of
the xpath engine, a logger is monkey patched into the xpath py-module.

```
make test.unit
TEST      tests/unit
......EE...................
======================================================================
ERROR: test_response (tests.unit.engines.test_xpath.TestXpathEngine.test_response)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/unit/engines/test_xpath.py", line 60, in test_response
    self.assertEqual(xpath.response(response), [])
                     ^^^^^^^^^^^^^^^^^^^^^^^^
  File "./searx/engines/xpath.py", line 309, in response
    logger.debug("found %s results", len(results))
    ^^^^^^
NameError: name 'logger' is not defined

======================================================================
ERROR: test_response_results_xpath (tests.unit.engines.test_xpath.TestXpathEngine.test_response_results_xpath)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./tests/unit/engines/test_xpath.py", line 102, in test_response_results_xpath
    self.assertEqual(xpath.response(response), [])
                     ^^^^^^^^^^^^^^^^^^^^^^^^
  File "./searx/engines/xpath.py", line 309, in response
    logger.debug("found %s results", len(results))
    ^^^^^^
NameError: name 'logger' is not defined
```

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
2024-06-28 08:54:19 +02:00
..
engines [fix] unit test_xpath.py: name 'logger' is not defined 2024-06-28 08:54:19 +02:00
network [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
processors [fix] implement tests and remove usage of gen_useragent in engines 2024-06-23 11:51:41 +02:00
settings [mod] remove X-XSS-Protection headers 2024-01-31 17:23:41 +01:00
__init__.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
test_answerers.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
test_engines_init.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
test_exceptions.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
test_external_bangs.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
test_locales.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
test_plugins.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
test_preferences.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
test_query.py [fix] engine unit tests. 2024-06-23 09:24:05 +02:00
test_results.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
test_search.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
test_settings_loader.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
test_utils.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
test_webadapter.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
test_webapp.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00
test_webutils.py [mod] pylint all files with one profile / drop PYLINT_SEARXNG_DISABLE_OPTION 2024-03-11 14:55:38 +01:00