-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not use CRS operations before initializing QgsApplication [#56]
- Loading branch information
Showing
6 changed files
with
38 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import unittest | ||
from pathlib import Path | ||
|
||
from qgis.core import ( | ||
QgsCoordinateReferenceSystem, | ||
QgsRasterLayer, | ||
) | ||
|
||
|
||
class TestCrs(unittest.TestCase): | ||
""" | ||
These tests make sure CRS works as intended when pytest-qgis is active | ||
""" | ||
|
||
def test_crs_copying(self): | ||
crs1 = QgsCoordinateReferenceSystem("EPSG:4326") | ||
assert crs1.isValid() | ||
crs2 = QgsCoordinateReferenceSystem.fromWkt(crs1.toWkt()) | ||
assert crs1.toWkt() == crs2.toWkt() | ||
assert crs2.isValid() # <-- raises error | ||
|
||
def test_crs_raster(self): | ||
raster_path = Path(Path(__file__).parent, "data", "small_raster.tif") | ||
layer = QgsRasterLayer(raster_path.as_posix()) | ||
assert layer.crs().toWkt() | ||
assert layer.crs().isValid() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters