mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 20:54:50 -04:00
Create a mechanism for marking tests "logcontext clean" (#8399)
This commit is contained in:
parent
bd715e1278
commit
5e3ca12b15
4 changed files with 41 additions and 21 deletions
|
@ -23,7 +23,7 @@ import logging
|
|||
import time
|
||||
from typing import Optional, Tuple, Type, TypeVar, Union
|
||||
|
||||
from mock import Mock
|
||||
from mock import Mock, patch
|
||||
|
||||
from canonicaljson import json
|
||||
|
||||
|
@ -169,6 +169,19 @@ def INFO(target):
|
|||
return target
|
||||
|
||||
|
||||
def logcontext_clean(target):
|
||||
"""A decorator which marks the TestCase or method as 'logcontext_clean'
|
||||
|
||||
... ie, any logcontext errors should cause a test failure
|
||||
"""
|
||||
|
||||
def logcontext_error(msg):
|
||||
raise AssertionError("logcontext error: %s" % (msg))
|
||||
|
||||
patcher = patch("synapse.logging.context.logcontext_error", new=logcontext_error)
|
||||
return patcher(target)
|
||||
|
||||
|
||||
class HomeserverTestCase(TestCase):
|
||||
"""
|
||||
A base TestCase that reduces boilerplate for HomeServer-using test cases.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue