diff options
| author | Markus Heiser <markus.heiser@darmarIT.de> | 2019-12-29 09:47:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-29 09:47:06 +0100 |
| commit | 36e72a46192235615f63a02984ab88c70145b0ec (patch) | |
| tree | 0c2e238ed8fd03a95a090692d0d761fe2ea13d79 /searx/testing.py | |
| parent | b2e1ee8d35050033b41765a2de49c0eea5f8b4b4 (diff) | |
| parent | f6d66c0f6f1d8f1f583d9000ee0123450cce8130 (diff) | |
Merge branch 'master' into fix-engine-spotify
Diffstat (limited to 'searx/testing.py')
| -rw-r--r-- | searx/testing.py | 12 |
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 |