Skip to content

Commit

Permalink
create different map canvas if tests are run in standalone qgis mode(…
Browse files Browse the repository at this point in the history
…non GUI)
  • Loading branch information
Samweli committed Nov 8, 2022
1 parent 0dc45be commit fbaf136
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions planet_explorer/tests/test_filters.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from qgis.core import QgsGeometry, QgsPoint, QgsPointXY, QgsWkbTypes
from qgis.gui import QgsRubberBand
from qgis.gui import QgsRubberBand, QgsMapCanvas
from qgis.utils import iface

from planet_explorer.gui.pe_filters import PlanetAOIFilter
Expand Down Expand Up @@ -63,7 +63,8 @@
def test_aoi_area_size_calculation(name, polygon, expected_size):
"""Tests the filter for calculating the aoi size in square kilometers"""
aoi_filter = PlanetAOIFilter()
aoi_box = QgsRubberBand(iface.mapCanvas(), QgsWkbTypes.PolygonGeometry)
canvas = iface.mapCanvas() if iface else QgsMapCanvas()
aoi_box = QgsRubberBand(canvas, QgsWkbTypes.PolygonGeometry)

geometry = QgsGeometry.fromPolygonXY([polygon])
aoi_box.setToGeometry(geometry)
Expand Down

0 comments on commit fbaf136

Please sign in to comment.