From 333e54943d945a1afcb2ac5a82dd6edcf052be2d Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Sat, 3 Aug 2019 13:23:36 +0200 Subject: [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 --- searx/testing.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'searx/testing.py') 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 -- cgit v1.2.3