[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
This commit is contained in:
Alexandre Flament 2019-08-03 13:23:36 +02:00 committed by GitHub
parent d24e7948eb
commit 333e54943d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 6 deletions

View file

@ -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