Skip to content
Permalink
Browse files

Add a __repr__ method to QgsMimeDataUtils::Uri

  • Loading branch information
nyalldawson committed Nov 5, 2018
1 parent e7900a3 commit 82baff87d4cb0d40a88e03912297d7096220fb07
@@ -71,6 +71,12 @@ Gets mesh layer from uri if possible, otherwise returns 0 and error is set
QString uri;
QStringList supportedCrs;
QStringList supportedFormats;

SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsMimeDataUtils::Uri (%1): %2>" ).arg( sipCpp->providerKey, sipCpp->uri );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End
};
typedef QList<QgsMimeDataUtils::Uri> UriList;

@@ -87,6 +87,14 @@ class CORE_EXPORT QgsMimeDataUtils
QString uri;
QStringList supportedCrs;
QStringList supportedFormats;

#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsMimeDataUtils::Uri (%1): %2>" ).arg( sipCpp->providerKey, sipCpp->uri );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
% End
#endif
};
typedef QList<QgsMimeDataUtils::Uri> UriList;

@@ -17,7 +17,8 @@
from PyQt5.QtCore import QVariant
from qgis.testing import unittest, start_app
from qgis.core import QgsGeometry, QgsPoint, QgsPointXY, QgsCircle, QgsCircularString, QgsCompoundCurve,\
QgsCurvePolygon, QgsEllipse, QgsLineString, QgsMultiCurve, QgsRectangle, QgsExpression, QgsField, QgsError
QgsCurvePolygon, QgsEllipse, QgsLineString, QgsMultiCurve, QgsRectangle, QgsExpression, QgsField, QgsError,\
QgsMimeDataUtils

start_app()

@@ -125,6 +126,12 @@ def testQgsErrorRepr(self):
e = QgsError('you done wrong son', 'dad')
self.assertEqual(e.__repr__(), "<QgsError: dad you done wrong son>")

def testQgsMimeDataUri(self):
d = QgsMimeDataUtils.Uri()
d.uri = 'my_uri'
d.providerKey = 'my_provider'
self.assertEqual(d.__repr__(), "<QgsMimeDataUtils::Uri (my_provider): my_uri>")


if __name__ == "__main__":
unittest.main()

0 comments on commit 82baff8

Please sign in to comment.
You can’t perform that action at this time.