Skip to content

Comments

TST: Use context manager for WarpedVRT#3463

Merged
snowman2 merged 1 commit intorasterio:mainfrom
snowman2:vrt_context
Dec 9, 2025
Merged

TST: Use context manager for WarpedVRT#3463
snowman2 merged 1 commit intorasterio:mainfrom
snowman2:vrt_context

Conversation

@snowman2
Copy link
Member

@snowman2 snowman2 commented Dec 9, 2025

Continuation of #3444

Addresses:
https://github.com/rasterio/rasterio/actions/runs/20071106104/job/57573146383

__________________________ test_warped_vrt_add_alpha ___________________________

dsrec = <function dsrec.<locals>.func at 0x7f5609d53740>
path_rgb_byte_tif = '/home/runner/work/rasterio/rasterio/tests/data/RGB.byte.tif'

    def test_warped_vrt_add_alpha(dsrec, path_rgb_byte_tif):
        """A VirtualVRT has the expected VRT properties."""
        with rasterio.Env() as env:
            with rasterio.open(path_rgb_byte_tif) as src:
                vrt = WarpedVRT(src, crs=DST_CRS, add_alpha=True)
    
                records = dsrec(env)
>               assert len(records) == 1
E               AssertionError: assert 3 == 1
E                +  where 3 = len(['  1 N GTiff       -1 791x718x1 /home/runner/work/rasterio/rasterio/tests/data/RGB2.byte.tif.msk', '  1 N GTiff       -1 791x718x3 /home/runner/work/rasterio/rasterio/tests/data/RGB2.byte.tif', '  2 N GTiff       -1 791x718x3 /home/runner/work/rasterio/rasterio/tests/data/RGB.byte.tif'])

tests/test_warpedvrt.py:71: AssertionError
------------------------------ Captured log call -------------------------------
WARNING  rasterio._env:test_warpedvrt.py:68 CPLE_NotSupported in transformer options does not support option INIT_DEST
________________________________ test_warp_warp ________________________________

dsrec = <function dsrec.<locals>.func at 0x7f5609da56f0>
path_rgb_byte_tif = '/home/runner/work/rasterio/rasterio/tests/data/RGB.byte.tif'

    def test_warp_warp(dsrec, path_rgb_byte_tif):
        """Vincent! :P"""
        with rasterio.Env() as env:
    
            with rasterio.open(path_rgb_byte_tif) as src:
                # We should have one open dataset with a refcount of 1.
                records = dsrec(env)
>               assert len(records) == 1
E               AssertionError: assert 4 == 1
E                +  where 4 = len(['  1 N GTiff       -1 791x718x3 /home/runner/work/rasterio/rasterio/tests/data/RGB.byte.tif', '  1 N GTiff       -1 791x718x1 /home/runner/work/rasterio/rasterio/tests/data/RGB2.byte.tif.msk', '  1 N GTiff       -1 791x718x3 /home/runner/work/rasterio/rasterio/tests/data/RGB2.byte.tif', '  1 N GTiff       -1 791x718x3 /home/runner/work/rasterio/rasterio/tests/data/RGB.byte.tif'])

tests/test_warpedvrt.py:479: AssertionError
______________________________ test_open_datasets ______________________________

capfd = <_pytest.capture.CaptureFixture object at 0x7f5609d56250>
path_rgb_byte_tif = '/home/runner/work/rasterio/rasterio/tests/data/RGB.byte.tif'

    def test_open_datasets(capfd, path_rgb_byte_tif):
        """Number of open datasets is expected"""
        with rasterio.Env() as env:
    
            with rasterio.open(path_rgb_byte_tif) as src:
                env._dump_open_datasets()
                captured = capfd.readouterr()
                assert "1 N GTiff" in captured.err
                assert "1 S GTiff" not in captured.err
    
                with WarpedVRT(src) as vrt:
                    env._dump_open_datasets()
                    captured = capfd.readouterr()
                    assert "2 N GTiff" in captured.err
    
            env._dump_open_datasets()
            captured = capfd.readouterr()
>           assert "1 N GTiff" not in captured.err
E           AssertionError: assert '1 N GTiff' not in 'Open GDAL D...B.byte.tif\n'
E             
E             '1 N GTiff' is contained here:
E               Open GDAL Datasets:
E                 1 N GTiff       -1 791x718x1 /home/runner/work/rasterio/rasterio/tests/data/RGB2.byte.tif.msk
E             ?   +++++++++
E                 1 N GTiff       -1 791x718x3 /home/runner/work/rasterio/rasterio/tests/data/RGB2.byte.tif
E                 1 N GTiff       -1 791x718x3 /home/runner/work/rasterio/rasterio/tests/data/RGB.byte.tif

tests/test_warpedvrt.py:469: AssertionError

@snowman2 snowman2 added this to the 1.5.0 milestone Dec 9, 2025
@snowman2 snowman2 added bug testing backport-1.4 To be backported to maint-1.4 labels Dec 9, 2025
@snowman2 snowman2 modified the milestones: 1.5.0, 1.4.4 Dec 9, 2025
@snowman2 snowman2 merged commit da689bb into rasterio:main Dec 9, 2025
13 of 25 checks passed
@snowman2 snowman2 deleted the vrt_context branch December 9, 2025 20:07
snowman2 added a commit to snowman2/rasterio that referenced this pull request Dec 9, 2025
snowman2 added a commit to snowman2/rasterio that referenced this pull request Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-1.4 To be backported to maint-1.4 bug testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant