Improve removing quotes logic
Cover case when sting consists of one quote only. Change-Id: I1fed30f6e365e18d3e3ec11d436a432b08c6c344
This commit is contained in:
parent
baba7cfd65
commit
8ab5fa2d45
@ -93,6 +93,11 @@ class StringTypeTests(TypeTestHelper, unittest.TestCase):
|
||||
self.type_instance = types.String(quotes=True)
|
||||
self.assertConvertedValue('foo bar"', 'foo bar"')
|
||||
|
||||
def test_single_quote_is_invalid(self):
|
||||
self.type_instance = types.String(quotes=True)
|
||||
self.assertInvalid('"')
|
||||
self.assertInvalid("'")
|
||||
|
||||
def test_repr(self):
|
||||
t = types.String()
|
||||
self.assertEqual('String', repr(t))
|
||||
|
@ -144,7 +144,7 @@ class String(ConfigType):
|
||||
value = str(value)
|
||||
if self.quotes and value:
|
||||
if value[0] in "\"'":
|
||||
if value[-1] != value[0]:
|
||||
if len(value) == 1 or value[-1] != value[0]:
|
||||
raise ValueError('Non-closed quote: %s' % value)
|
||||
value = value[1:-1]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user