diff options
| author | Grant Lanham <contact@grantlanham.com> | 2024-10-05 16:10:21 +0200 |
|---|---|---|
| committer | Markus Heiser <markus.heiser@darmarIT.de> | 2024-10-15 08:10:52 +0200 |
| commit | d448def1a66afe9e0b702ac25ca921526a3f0ca2 (patch) | |
| tree | 3fa98723835ce47703e29085d4bd63c018f9d8ea /tests/unit/test_utils.py | |
| parent | 8ba203c72b76800110f0757de547eaab7f1773d1 (diff) | |
[refactor] unit tests (continued) - plugins
This commit includes some refactoring in unit tests. As we test more plugins,
it seems unweildy to include every test class in the test_plugins.py file. This
patch split apart all of the test plugins to their own respective files,
including the new test_plugin_calculator.py file.
Diffstat (limited to 'tests/unit/test_utils.py')
| -rw-r--r-- | tests/unit/test_utils.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 4306d0790..4c7ebaec7 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -1,16 +1,21 @@ # SPDX-License-Identifier: AGPL-3.0-or-later # pylint: disable=missing-module-docstring, invalid-name +import random +import string import lxml.etree from lxml import html from parameterized.parameterized import parameterized from searx.exceptions import SearxXPathSyntaxException, SearxEngineXPathException from searx import utils - from tests import SearxTestCase +def random_string(length, choices=string.ascii_letters): + return ''.join(random.choice(choices) for _ in range(length)) + + class TestUtils(SearxTestCase): # pylint: disable=missing-class-docstring def test_gen_useragent(self): self.assertIsInstance(utils.gen_useragent(), str) @@ -234,4 +239,4 @@ class TestXPathUtils(SearxTestCase): # pylint: disable=missing-class-docstring self.assertIsNone(l) with self.assertRaises(ValueError): - utils.detect_language(None) + utils.detect_language(None) # type: ignore |