Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 26, 2017
1 parent f04587e commit a95aeca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion python/plugins/processing/tools/dataobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

from qgis.core import (QgsVectorFileWriter,
QgsMapLayer,
QgsDataProvider,
QgsRasterLayer,
QgsWkbTypes,
QgsVectorLayer,
Expand Down Expand Up @@ -309,7 +310,7 @@ def getRasterSublayer(path, param):
subLayer = subLayer[1:]
else:
# remove driver name and file name
subLayer.replace(subLayer.split(":")[0], "")
subLayer.replace(subLayer.split(QgsDataProvider.SUBLAYER_SEPARATOR)[0], "")
subLayer.replace(path, "")
# remove any : or " left over
if subLayer.startswith(":"):
Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/testqgsrastersublayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ void TestQgsRasterSubLayer::subLayersList()
Q_FOREACH ( const QString &s, mpRasterLayer->subLayers() )
{
qDebug() << "sublayer: " << s;
sublayers << s.split( QgsDataProvider::SUBLAYER_SEPARATOR ).last();
sublayers << s.split( ':' ).last();
}
qDebug() << "sublayers: " << sublayers.join( QStringLiteral( "," ) );
mReport += QStringLiteral( "sublayers:<br>%1<br>\n" ).arg( sublayers.join( QStringLiteral( "<br>" ) ) );
mReport += QStringLiteral( "expected:<br>%1<br>\n" ).arg( expected.join( QStringLiteral( "<br>" ) ) );
QVERIFY( sublayers == expected );
QCOMPARE( sublayers, expected );
mReport += QLatin1String( "<p>Passed</p>" );
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/src/python/test_provider_ogr.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import tempfile

from osgeo import gdal, ogr # NOQA
from qgis.core import (QgsFeature, QgsFeatureRequest, QgsSettings,
from qgis.core import (QgsFeature, QgsFeatureRequest, QgsSettings, QgsDataProvider,
QgsVectorDataProvider, QgsVectorLayer, QgsWkbTypes, QgsNetworkAccessManager)
from qgis.testing import start_app, unittest

Expand Down Expand Up @@ -111,7 +111,7 @@ def testMixOfPolygonCurvePolygon(self):
vl = QgsVectorLayer('{}|layerid=0'.format(datasource), 'test', 'ogr')
self.assertTrue(vl.isValid())
self.assertEqual(len(vl.dataProvider().subLayers()), 1)
self.assertEqual(vl.dataProvider().subLayers()[0], '0:testMixOfPolygonCurvePolygon:4:CurvePolygon:')
self.assertEqual(vl.dataProvider().subLayers()[0], QgsDataProvider.SUBLAYER_SEPARATOR.join(['0', 'testMixOfPolygonCurvePolygon', '4', 'CurvePolygon', '']))

def testMixOfLineStringCompoundCurve(self):

Expand All @@ -127,7 +127,7 @@ def testMixOfLineStringCompoundCurve(self):
vl = QgsVectorLayer('{}|layerid=0'.format(datasource), 'test', 'ogr')
self.assertTrue(vl.isValid())
self.assertEqual(len(vl.dataProvider().subLayers()), 1)
self.assertEqual(vl.dataProvider().subLayers()[0], '0:testMixOfLineStringCompoundCurve:5:CompoundCurve:')
self.assertEqual(vl.dataProvider().subLayers()[0], QgsDataProvider.SUBLAYER_SEPARATOR.join(['0', 'testMixOfLineStringCompoundCurve', '5', 'CompoundCurve', '']))

def testGpxElevation(self):
# GPX without elevation data
Expand Down

0 comments on commit a95aeca

Please sign in to comment.