Skip to content
Permalink
Browse files
Fix use of deprecated API in test_qgsmapcanvas.py
  • Loading branch information
nyalldawson committed Sep 6, 2021
1 parent 88158d8 commit 77729d16bea3089bdf3966083953ad094b1cfd00
Showing with 7 additions and 8 deletions.
  1. +7 −8 tests/src/python/test_qgsmapcanvas.py
@@ -64,7 +64,7 @@ def testGettersSetters(self):
def testDeferredUpdate(self):
""" test that map canvas doesn't auto refresh on deferred layer update """
canvas = QgsMapCanvas()
canvas.setDestinationCrs(QgsCoordinateReferenceSystem(4326))
canvas.setDestinationCrs(QgsCoordinateReferenceSystem('EPSG:4326'))
canvas.setFrameStyle(0)
canvas.resize(600, 400)
self.assertEqual(canvas.width(), 600)
@@ -106,7 +106,7 @@ def testDeferredUpdate(self):
def testRefreshOnTimer(self):
""" test that map canvas refreshes with auto refreshing layers """
canvas = QgsMapCanvas()
canvas.setDestinationCrs(QgsCoordinateReferenceSystem(4326))
canvas.setDestinationCrs(QgsCoordinateReferenceSystem('EPSG:4326'))
canvas.setFrameStyle(0)
canvas.resize(600, 400)
self.assertEqual(canvas.width(), 600)
@@ -168,7 +168,7 @@ def testRefreshOnTimer(self):
def testCancelAndDestroy(self):
""" test that nothing goes wrong if we destroy a canvas while a job is canceling """
canvas = QgsMapCanvas()
canvas.setDestinationCrs(QgsCoordinateReferenceSystem(4326))
canvas.setDestinationCrs(QgsCoordinateReferenceSystem('EPSG:4326'))
canvas.setFrameStyle(0)
canvas.resize(600, 400)

@@ -195,7 +195,7 @@ def testCancelAndDestroy(self):

def testMapTheme(self):
canvas = QgsMapCanvas()
canvas.setDestinationCrs(QgsCoordinateReferenceSystem(4326))
canvas.setDestinationCrs(QgsCoordinateReferenceSystem('EPSG:4326'))
canvas.setFrameStyle(0)
canvas.resize(600, 400)
self.assertEqual(canvas.width(), 600)
@@ -360,7 +360,7 @@ def testMapTheme(self):
def testMainAnnotationLayerRendered(self):
""" test that main annotation layer is rendered above all other layers """
canvas = QgsMapCanvas()
canvas.setDestinationCrs(QgsCoordinateReferenceSystem(4326))
canvas.setDestinationCrs(QgsCoordinateReferenceSystem('EPSG:4326'))
canvas.setFrameStyle(0)
canvas.resize(600, 400)
self.assertEqual(canvas.width(), 600)
@@ -393,7 +393,7 @@ def testMainAnnotationLayerRendered(self):
self.assertFalse(self.canvasImageCheck('main_annotation_layer', 'main_annotation_layer', canvas))

annotation_layer = QgsProject.instance().mainAnnotationLayer()
annotation_layer.setCrs(QgsCoordinateReferenceSystem(4326))
annotation_layer.setCrs(QgsCoordinateReferenceSystem('EPSG:4326'))
annotation_geom = QgsGeometry.fromRect(QgsRectangle(12, 30, 18, 33))
annotation = QgsAnnotationPolygonItem(annotation_geom.constGet().clone())
sym3 = QgsFillSymbol.createSimple({'color': '#ff0000', 'outline_style': 'no'})
@@ -571,7 +571,7 @@ def testLockedScale(self):

def test_rendered_items(self):
canvas = QgsMapCanvas()
canvas.setDestinationCrs(QgsCoordinateReferenceSystem(4326))
canvas.setDestinationCrs(QgsCoordinateReferenceSystem('EPSG:4326'))
canvas.setFrameStyle(0)
canvas.resize(600, 400)
canvas.setCachingEnabled(True)
@@ -636,6 +636,5 @@ def test_rendered_items(self):
self.assertCountEqual([i.itemId() for i in results.renderedItems()], [i1_id, i2_id, i3_id])



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

0 comments on commit 77729d1

Please sign in to comment.