diff options
author | Zuul <zuul@review.opendev.org> | 2019-08-14 20:49:52 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2019-08-14 20:49:52 +0000 |
commit | c4d8fa7b88f3d952b7faabd89dc22123a1cb7e03 (patch) | |
tree | 1d553536f0ed601011c98a3cefe5eadf8e75106f | |
parent | 01a632e2432a868f7bfa1e1046ef1a699b092853 (diff) | |
parent | 8ab5fa2d458683066d31390f4625e9cda5583b7e (diff) | |
download | oslo-config-c4d8fa7b88f3d952b7faabd89dc22123a1cb7e03.tar.gz |
Merge "Improve removing quotes logic"6.11.1
-rw-r--r-- | oslo_config/tests/test_types.py | 5 | ||||
-rw-r--r-- | oslo_config/types.py | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/oslo_config/tests/test_types.py b/oslo_config/tests/test_types.py index 78e23b5..e4f4779 100644 --- a/oslo_config/tests/test_types.py +++ b/oslo_config/tests/test_types.py @@ -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)) diff --git a/oslo_config/types.py b/oslo_config/types.py index 652599b..223fffb 100644 --- a/oslo_config/types.py +++ b/oslo_config/types.py @@ -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] |