summaryrefslogtreecommitdiff
path: root/searx/testing.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2019-08-03 13:23:36 +0200
committerGitHub <noreply@github.com>2019-08-03 13:23:36 +0200
commit333e54943d945a1afcb2ac5a82dd6edcf052be2d (patch)
treea3cd0090ad19b1aa392fa0a7b11c0c48b612fd5f /searx/testing.py
parentd24e7948ebd8aaa25a1907c225e1d2d3de37c17c (diff)
[fix] fix monkey patch in test_webapp.py (#1667)
at the end of test_webapp.py, the monkey patch of searx.search.Search was not revert which lead to side effects on other tests close #1663
Diffstat (limited to 'searx/testing.py')
-rw-r--r--searx/testing.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/searx/testing.py b/searx/testing.py
index 08a53e3f4..a3616dc12 100644
--- a/searx/testing.py
+++ b/searx/testing.py
@@ -80,6 +80,18 @@ class SearxTestCase(TestCase):
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)
+
if __name__ == '__main__':
import sys