[IMP] remove unwanted log in test

bzr revid: chs@openerp.com-20120822110604-il0sxlvf592wasur
This commit is contained in:
Christophe Simonis 2012-08-22 13:06:04 +02:00
parent d3fcdb2ac7
commit 89f1693653
2 changed files with 22 additions and 7 deletions

View File

@ -42,15 +42,13 @@
-
!python {model: ir.model}: |
from tools.safe_eval import safe_eval
from tools.misc import mute_logger
try:
safe_eval('open("/etc/passwd","r")')
assert False, "safe_eval should not allow calling open() builtin"
with mute_logger('openerp.tools.safe_eval'):
safe_eval('open("/etc/passwd","r")')
assert False, "safe_eval should not allow calling open() builtin"
except NameError:
pass
except:
# NameError should be raised because open() builtin is not found,
# but other exceptions probably indicate that open() was executed!
assert False, "safe_eval should not allow calling open() builtin"
pass
-
"ORM test: verify that parent_store computation are going right"

View File

@ -55,6 +55,7 @@ try:
from html2text import html2text
except ImportError:
html2text = None
import contextlib
import openerp.loglevels as loglevels
import openerp.pooler as pooler
@ -1140,4 +1141,20 @@ class UnquoteEvalContext(defaultdict):
def __missing__(self, key):
return unquote(key)
class MuteFilter(logging.Filter):
def filter(self, record):
return 0
@contextlib.contextmanager
def mute_logger(*loggers):
mute = MuteFilter()
for logger in loggers:
logging.getLogger(logger).addFilter(mute)
yield
for logger in loggers:
logging.getLogger(logger).removeFilter(mute)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: