Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

test_helpers: Use mock.patch.multiple.

Steve Howellce70d08cbf2b
diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py
index b6d2b6a8afc..5f5264c3f6a 100644
--- a/zerver/lib/test_helpers.py
+++ b/zerver/lib/test_helpers.py
@@ -136,13 +136,8 @@ def simulated_empty_cache() -> Iterator[List[Tuple[str, Union[str, List[str]], O
cache_queries.append(('getmany', keys, cache_name))
return {}
- old_get = cache.cache_get
- old_get_many = cache.cache_get_many
- cache.cache_get = my_cache_get
- cache.cache_get_many = my_cache_get_many
- yield cache_queries
- cache.cache_get = old_get
- cache.cache_get_many = old_get_many
+ with mock.patch.multiple(cache, cache_get=my_cache_get, cache_get_many=my_cache_get_many):
+ yield cache_queries
@contextmanager
def queries_captured(include_savepoints: bool=False) -> Generator[