mirror of
https://github.com/searxng/searxng.git
synced 2025-07-14 00:39:18 +02: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:
parent
d24e7948eb
commit
333e54943d
2 changed files with 19 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue