Remove handling of 'u' prefix
... because the prefix is no longer printed in Python 3.
In python 2
>>> print({u'foo': u'baa'})
{u'foo': u'baa'}
>>> print([u'foo', 'baa'])
[u'foo', 'baa']
In python 3
>>> print({u'foo': u'baa'})
{'foo': 'baa'}
>>> print([u'foo', 'baa'])
['foo', 'baa']
Change-Id: I21de3254caad3cf1805e41faa2ac8d458e61acbe
This commit is contained in:
@@ -214,7 +214,7 @@ Puppet::Type.type(:glance_image).provide(
|
||||
end
|
||||
|
||||
def self.pythondict2hash(input)
|
||||
return JSON.parse(input.gsub(/u'(\w*)'/, '"\1"').gsub(/'/, '"').gsub(/False/,'false').gsub(/True/,'true'))
|
||||
return JSON.parse(input.gsub(/'/, '"').gsub(/False/,'false').gsub(/True/,'true'))
|
||||
end
|
||||
|
||||
def self.parsestring(input)
|
||||
|
||||
@@ -81,7 +81,7 @@ visibility="public"
|
||||
|
||||
describe '#pythondict2hash' do
|
||||
it 'should return a hash with key-value when provided with a unicode python dict' do
|
||||
s = "{u'key': 'value', u'key2': 'value2'}"
|
||||
s = "{'key': 'value', 'key2': 'value2'}"
|
||||
expect(provider_class.pythondict2hash(s)).to eq({"key"=>"value", "key2"=>"value2"})
|
||||
end
|
||||
|
||||
@@ -103,7 +103,7 @@ visibility="public"
|
||||
end
|
||||
|
||||
it 'should call pythondict2hash when provided with a hash' do
|
||||
s = "{u'key': 'value', u'key2': 'value2'}"
|
||||
s = "{'key': 'value', 'key2': 'value2'}"
|
||||
expect(provider_class.parsestring(s)).to eq({"key"=>"value", "key2"=>"value2"})
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user