Clean error.message

Unfortunately the way that jsonschema is calling %r on its property
and then encoding the complete message means I've had to do this
manual way of removing the literal string prefix, u'.

eg:

key = 'extends'
message = "Invalid value for %r" % key
error.message = message.encode("utf-8")"

results in:

"Invalid value for u'extends'"

Performing a replace to strip out the extra "u'", does not change the
encoding of the string, it is at this point the character u followed
by a '.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
Mazz Mosley 2015-08-10 15:33:47 +01:00
commit ece6a72712
2 changed files with 7 additions and 4 deletions

View file

@ -659,7 +659,7 @@ class ExtendsTest(unittest.TestCase):
)
def test_extends_validation_missing_service_key(self):
with self.assertRaisesRegexp(ConfigurationError, "u'service' is a required property"):
with self.assertRaisesRegexp(ConfigurationError, "'service' is a required property"):
config.load(
config.ConfigDetails(
{