rasterio/tests/test_open.py
Sean Gillies 24d79d54af
Merge 1.4.3 (#3270)
* Eliminate boundless reads in merge, new compositing implementation (#3234)

* Eliminate boundless reads in merge, new compositing implementation

Resolves #3228

* Fix nits

* Compare non-zero mean of arrays

* Implement and use Window.align()

Combines the effects of Window.round_offsets and
Window.round_lengths, producing the same effect as gdal_merge.py

* Remove unused math import

* Add more docs about align()

Also increase the fraction used in round_offsets() to be
consistent with align()

* Move align() to a private func, use two existing methods in tests

* Add a test for merging WarpedVRTs (#3237)

Resolves #3196

* Backport of #3217 (#3243)

* Backport of #3217

* Update change log

* Increment GDAL and Python versions for CI (#3244)

* Rewrite _matches() to better support to_authority() and to_epsg() (#3255)

* Rewrite _matches() to better support to_authority() and to_epsg()

Resolves #3239

* Remove list() call and update change log

* Use to_epsg() in is_epsg_code() (#3258)

* Use to_epsg() in is_epsg_code()

Resolves #3248

* Update change log

* Allow MRF compression to surface in properties (#3259)

* Allow MRF compression to surface in properties

Resolves #3256

* Update change log

* Register drivers at most once per process (#3260)

* Register drivers at most once per process

Resolves #3250

* Appease flake8

* Add a note about GDAL_SKIP in the change log

* Support all GDALFillNodata() options in rasterio.fill (#3265)

* Support all GDALFillNodata() options

Resolve #3175.

* Cast values to str and update docs

* Update change log

* Prevent rasterio from trying to open a dataset object (#3266)

Resolves #3105.

* Fix typos discovered by codespell (#3264) (#3267)

* Fix typos discovered by codespell

* crasher



---------

Co-authored-by: Christian Clauss <cclauss@me.com>

* Fix erroneous masking of 0-valued data (#3268)

* Fix erroneous masking of 0-valued data

Resolves #3245

* Add an assertion about data values and update change log

* This is 1.4.3

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2024-12-02 10:43:14 -07:00

44 lines
1.0 KiB
Python

import pytest
import rasterio
from pathlib import Path
def test_open_bad_path():
with pytest.raises(TypeError):
rasterio.open(3.14)
def test_open_bad_path_2(path_rgb_byte_tif):
with rasterio.open(path_rgb_byte_tif) as dst:
with pytest.raises(TypeError):
rasterio.open(dst)
def test_open_bad_mode_1():
with pytest.raises(TypeError):
rasterio.open("tests/data/RGB.byte.tif", mode=3.14)
def test_open_bad_mode_2():
with pytest.raises(ValueError):
rasterio.open("tests/data/RGB.byte.tif", mode="foo")
def test_open_bad_driver():
with pytest.raises(TypeError):
rasterio.open("tests/data/RGB.byte.tif", mode="r", driver=3.14)
def test_open_pathlib_path():
tif = Path.cwd() / 'tests' / 'data' / 'RGB.byte.tif'
with rasterio.open(tif) as src:
assert src.count == 3
def test_open_pathlike():
class MyPath:
def __fspath__(self):
return str(Path.cwd() / 'tests' / 'data' / 'RGB.byte.tif')
with rasterio.open(MyPath()) as src:
assert src.count == 3