rasterio/tests/test_data_paths.py
Sean Gillies ff94da7f74
Check for data files at builtin locations (#1639)
* Check for data files at builtin locations

If we have them, don't set GDAL_DATA or PROJ_LIB.

Resolves #1631

* Include mock on Python 2.7
2019-02-25 20:40:06 -07:00

49 lines
1.3 KiB
Python

"""Tests of GDAL and PROJ data finding"""
import os.path
from click.testing import CliRunner
import pytest
import rasterio
from rasterio._env import GDALDataFinder, PROJDataFinder
from rasterio.rio.main import main_group
@pytest.mark.wheel
def test_gdal_data():
"""Get GDAL data path from a wheel"""
assert GDALDataFinder().search() == os.path.join(os.path.dirname(rasterio.__file__), 'gdal_data')
def test_gdal_data_find_file():
"""Find_file shouldn't raise any exceptions"""
GDALDataFinder().find_file("header.dxf")
@pytest.mark.wheel
def test_proj_data():
"""Get GDAL data path from a wheel"""
assert PROJDataFinder().search() == os.path.join(os.path.dirname(rasterio.__file__), 'proj_data')
def test_proj_data_has_data():
"""has_data shouldn't raise any exceptions"""
PROJDataFinder().has_data()
@pytest.mark.wheel
def test_env_gdal_data():
runner = CliRunner()
result = runner.invoke(main_group, ['env', '--gdal-data'])
assert result.exit_code == 0
assert result.output.strip() == os.path.join(os.path.dirname(rasterio.__file__), 'gdal_data')
@pytest.mark.wheel
def test_env_proj_data():
runner = CliRunner()
result = runner.invoke(main_group, ['env', '--proj-data'])
assert result.exit_code == 0
assert result.output.strip() == os.path.join(os.path.dirname(rasterio.__file__), 'proj_data')