mirror of
https://github.com/searxng/searxng.git
synced 2025-12-23 04:00:02 +00:00
[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:
committed by
GitHub
parent
d24e7948eb
commit
333e54943d
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user