Fix QgsXmlUtils reading list to variant and add test

This commit is contained in:
Matthias Kuhn 2017-03-09 13:46:40 +01:00
parent 0170580019
commit fc92e2a63e
2 changed files with 13 additions and 2 deletions

View File

@ -189,8 +189,7 @@ QVariant QgsXmlUtils::readVariant( const QDomElement &element )
for ( int i = 0; i < values.count(); ++i )
{
QDomElement elem = values.at( i ).toElement();
if ( elem.tagName() == QLatin1String( "e" ) )
list.append( readVariant( elem ) );
list.append( readVariant( elem ) );
}
return list;
}

View File

@ -77,6 +77,18 @@ class TestQgsXmlUtils(unittest.TestCase):
self.assertEquals(my_properties, prop2)
def test_list(self):
"""
Test that lists are correctly loaded and written
"""
doc = QDomDocument("properties")
my_properties = [1, 4, 'a', 'test', 7.9]
elem = QgsXmlUtils.writeVariant(my_properties, doc)
prop2 = QgsXmlUtils.readVariant(elem)
self.assertEquals(my_properties, prop2)
def test_complex(self):
"""
Test that maps are correctly loaded and written