summaryrefslogtreecommitdiff
path: root/tests/__init__.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-09-02 16:01:34 +0200
committerAlexandre Flament <alex@al-f.net>2021-09-02 16:01:34 +0200
commitb9c73fb69784726608d1a2d72b7a17f777d30b9d (patch)
treee1446c28afb7c49328ae7f9279b11c072c5b52c6 /tests/__init__.py
parent065b4dab56bf3c374cab7896314168e9d3106171 (diff)
downloadsearxng-b9c73fb69784726608d1a2d72b7a17f777d30b9d.tar.gz
searxng-b9c73fb69784726608d1a2d72b7a17f777d30b9d.zip
[mod] move searx/testing.py to the tests directory
move robot tests to tests.robot manage calls "python -m tests.robot"
Diffstat (limited to 'tests/__init__.py')
-rw-r--r--tests/__init__.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index cb43fc22a..d4b101cc4 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,5 +1,47 @@
import os
+import aiounittest
+
os.environ['SEARX_DEBUG'] = '1'
os.environ['SEARX_DISABLE_ETC_SETTINGS'] = '1'
os.environ.pop('SEARX_SETTINGS_PATH', None)
+
+
+class SearxTestLayer:
+ """Base layer for non-robot tests."""
+
+ __name__ = 'SearxTestLayer'
+
+ @classmethod
+ def setUp(cls):
+ pass
+
+ @classmethod
+ def tearDown(cls):
+ pass
+
+ @classmethod
+ def testSetUp(cls):
+ pass
+
+ @classmethod
+ def testTearDown(cls):
+ pass
+
+
+class SearxTestCase(aiounittest.AsyncTestCase):
+ """Base test case for non-robot tests."""
+
+ layer = SearxTestLayer
+
+ def setattr4test(self, obj, attr, value):
+ """
+ setattr(obj, attr, value)
+ but reset to the previous value in the cleanup.
+ """
+ previous_value = getattr(obj, attr)
+
+ def cleanup_patch():
+ setattr(obj, attr, previous_value)
+ self.addCleanup(cleanup_patch)
+ setattr(obj, attr, value)