From 7a50b2eff90ea68a080cba0c40631ffc99af0d1b Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Mon, 26 Oct 2015 15:19:42 +0100 Subject: [PATCH] [FIX] Prevent error msg in test with context hack --- base_phone/base_phone.py | 10 ++++++---- base_phone/test/phonenum.yml | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/base_phone/base_phone.py b/base_phone/base_phone.py index 0d663be..b63ad7c 100644 --- a/base_phone/base_phone.py +++ b/base_phone/base_phone.py @@ -103,10 +103,12 @@ class PhoneCommon(models.AbstractModel): # by a user via the Web interface # logger is usefull when the record is created/written # via the webservices - _logger.error( - "Cannot reformat the phone number '%s' to " - "international format with region=%s" - % (vals.get(field), countrycode)) + # Just don't generate this error message during testing + if not context.get('yml_test'): + _logger.error( + "Cannot reformat the phone number '%s' to " + "international format with region=%s" + % (vals.get(field), countrycode)) if context.get('raise_if_phone_parse_fails'): raise Warning( _("Cannot reformat the phone number '%s' to " diff --git a/base_phone/test/phonenum.yml b/base_phone/test/phonenum.yml index e1e320e..fb50cf8 100644 --- a/base_phone/test/phonenum.yml +++ b/base_phone/test/phonenum.yml @@ -16,7 +16,7 @@ - Write invalid phone number - - !record {model: res.partner, id: partner3}: + !record {model: res.partner, id: partner3, context: {"yml_test": True}}: name: Jean Badphone phone: 42 -