Skip to content

Commit

Permalink
[processing] Don't use authid to compare layer CRSes
Browse files Browse the repository at this point in the history
Instead of QgsCoordinateReferenceSystem == operator, so that we
can correctly test equality of non-standard CRSes
  • Loading branch information
nyalldawson committed Jan 11, 2021
1 parent f8e5e0b commit 7478bca
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions python/testing/__init__.py
Expand Up @@ -29,7 +29,13 @@
import tempfile

from qgis.PyQt.QtCore import QVariant
from qgis.core import QgsApplication, QgsFeatureRequest, NULL
from qgis.core import (
QgsApplication,
QgsFeatureRequest,
QgsCoordinateReferenceSystem,
NULL
)

import unittest

# Get a backup, we will patch this one later
Expand Down Expand Up @@ -86,9 +92,12 @@ def checkLayersEqual(self, layer_expected, layer_result, use_asserts=False, **kw

# Compare CRS
if 'ignore_crs_check' not in compare or not compare['ignore_crs_check']:
expected_wkt = layer_expected.dataProvider().crs().toWkt(QgsCoordinateReferenceSystem.WKT_PREFERRED)
result_wkt = layer_result.dataProvider().crs().toWkt(QgsCoordinateReferenceSystem.WKT_PREFERRED)

if use_asserts:
_TestCase.assertEqual(self, layer_expected.dataProvider().crs().authid(), layer_result.dataProvider().crs().authid())
elif not layer_expected.dataProvider().crs().authid() == layer_result.dataProvider().crs().authid():
_TestCase.assertEqual(self, layer_expected.dataProvider().crs(), layer_result.dataProvider().crs())
elif layer_expected.dataProvider().crs() != layer_result.dataProvider().crs():
return False

# Compare features
Expand Down

0 comments on commit 7478bca

Please sign in to comment.