mirror of
https://github.com/rasterio/rasterio.git
synced 2025-12-08 17:36:12 +00:00
fix some tests (#2226)
add additional monkeypatch
skip on windows for now, unclear what intent of test is
removed third slash that is the anchor ('/') on posix but would be 'C' on windows
make ParsedPath.from_uri consistent with as_posix usage in init
fix tests
This commit is contained in:
parent
7ef68fe082
commit
1b5f96d6e5
@ -71,7 +71,7 @@ class ParsedPath(Path):
|
||||
parts = path.split('!')
|
||||
path = parts.pop() if parts else None
|
||||
archive = parts.pop() if parts else None
|
||||
return ParsedPath(path, archive, scheme)
|
||||
return ParsedPath(pathlib.Path(path).as_posix(), archive, scheme)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
"""Test of boundless reads"""
|
||||
|
||||
import shutil
|
||||
from hypothesis import given
|
||||
import hypothesis.strategies as st
|
||||
import numpy
|
||||
@ -47,7 +48,7 @@ def test_hit_ovr(red_green):
|
||||
# overviews of green.tif over the red overviews and expect to find
|
||||
# green pixels below.
|
||||
green_ovr = red_green.join("green.tif.ovr")
|
||||
green_ovr.rename(red_green.join("red.tif.ovr"))
|
||||
shutil.move(green_ovr, red_green.join("red.tif.ovr"))
|
||||
assert not green_ovr.exists()
|
||||
with rasterio.open(str(red_green.join("red.tif.ovr"))) as ovr:
|
||||
data = ovr.read()
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
"""High level tests for Rasterio's ``GDALDataset`` abstractions."""
|
||||
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
try:
|
||||
from unittest.mock import MagicMock
|
||||
except ImportError:
|
||||
@ -16,12 +16,12 @@ from rasterio.transform import Affine
|
||||
|
||||
|
||||
def test_files(data):
|
||||
tif = str(data.join('RGB.byte.tif'))
|
||||
aux = tif + '.aux.xml'
|
||||
tif = Path(data).joinpath('RGB.byte.tif')
|
||||
aux = tif.parent.joinpath(tif.name + '.aux.xml')
|
||||
with open(aux, 'w'):
|
||||
pass
|
||||
with rasterio.open(tif) as src:
|
||||
assert src.files == [tif, aux]
|
||||
assert src.files == [tif.as_posix(), aux.as_posix()]
|
||||
|
||||
|
||||
def test_handle_closed(path_rgb_byte_tif):
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
"""Tests of rasterio.path"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
@ -95,6 +96,7 @@ def test_parse_gdal():
|
||||
assert parse_path('GDAL:filepath:varname').path == 'GDAL:filepath:varname'
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.platform == 'win32', reason="Checking behavior on posix, not win32")
|
||||
def test_parse_windows_path(monkeypatch):
|
||||
"""Return Windows paths unparsed"""
|
||||
monkeypatch.setattr(sys, 'platform', 'win32')
|
||||
|
||||
@ -103,7 +103,7 @@ def test_file_in_handler_with_vfs():
|
||||
uri = 'zip://tests/data/files.zip!/RGB.byte.tif'
|
||||
ctx = MockContext()
|
||||
retval = file_in_handler(ctx, 'INPUT', uri)
|
||||
assert retval.startswith('zip:///')
|
||||
assert retval.startswith('zip://')
|
||||
assert 'tests/data/files.zip!/RGB.byte.tif' in retval
|
||||
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import division
|
||||
import logging
|
||||
import shutil
|
||||
|
||||
import affine
|
||||
import boto3
|
||||
@ -388,7 +389,7 @@ def test_hit_ovr(red_green):
|
||||
# overviews of green.tif over the red overviews and expect to find
|
||||
# green pixels below.
|
||||
green_ovr = red_green.join("green.tif.ovr")
|
||||
green_ovr.rename(red_green.join("red.tif.ovr"))
|
||||
shutil.move(green_ovr, red_green.join("red.tif.ovr"))
|
||||
assert not green_ovr.exists()
|
||||
with rasterio.open(str(red_green.join("red.tif.ovr"))) as ovr:
|
||||
data = ovr.read()
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import re
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
|
||||
import affine
|
||||
@ -62,7 +63,7 @@ def test_no_crs(tmpdir):
|
||||
|
||||
@pytest.mark.gdalbin
|
||||
def test_context(tmpdir):
|
||||
name = str(tmpdir.join("test_context.tif"))
|
||||
name = Path(str(tmpdir.join("test_context.tif"))).as_posix()
|
||||
with rasterio.open(
|
||||
name, 'w',
|
||||
driver='GTiff', width=100, height=100, count=1,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user