summaryrefslogtreecommitdiff
path: root/tests/__init__.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarIT.de>2021-09-04 07:17:19 +0000
committerGitHub <noreply@github.com>2021-09-04 07:17:19 +0000
commitab4456b0d0f3e495f627311e576df03694e673ad (patch)
treea5732720882550ac321bd051f45ed080dae9083d /tests/__init__.py
parent16c19389a5aaf9cabae9d464537d5c848c96577e (diff)
parenta14ea6396e8e55b056065e6f0ce2032067e11385 (diff)
Merge pull request #281 from dalf/cleanup
Cleanup
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)