Skip to content

Broken test_cli_feature_stdin with click==8.2.1 #307

@mwtoews

Description

@mwtoews

With the current master branch, tests work fine with Python 3.9 (note commands use uv):

$ uv sync --extra=test --upgrade --python 3.9
...
$ uv run pytest tests/test_cli.py 
==================== test session starts ====================
platform linux -- Python 3.9.21, pytest-8.4.1, pluggy-1.6.0
rootdir: /home/mtoews/src/rasterstats
configfile: pytest.ini
plugins: cov-6.2.1
collected 8 items                                           

tests/test_cli.py ........                            [100%]

===================== 8 passed in 0.24s =====================

however, with newer Python versions this test always seems to fail:

$ uv sync --extra=test --upgrade --python 3.10
...
$ uv run pytest tests/test_cli.py 
==================== test session starts ====================
platform linux -- Python 3.10.12, pytest-8.4.1, pluggy-1.6.0
rootdir: /home/mtoews/src/rasterstats
configfile: pytest.ini
plugins: cov-6.2.1
collected 8 items                                           

tests/test_cli.py .F......                            [100%]

========================= FAILURES ==========================
__________________ test_cli_feature_stdin ___________________

    def test_cli_feature_stdin():
        raster = os.path.join(os.path.dirname(__file__), "data/slope.tif")
        vector = os.path.join(os.path.dirname(__file__), "data/feature.geojson")
    
        runner = CliRunner()
        warnings.simplefilter("ignore")
        result = runner.invoke(
            zonalstats,
            ["--raster", raster, "--stats", "all", "--prefix", "test_"],
            input=open(vector).read(),
        )
>       assert result.exit_code == 0
E       assert 1 == 0
E        +  where 1 = <Result SystemExit(1)>.exit_code

tests/test_cli.py:41: AssertionError
================== short test summary info ==================
FAILED tests/test_cli.py::test_cli_feature_stdin - assert 1 == 0
================ 1 failed, 7 passed in 0.43s ================

This could be an issue with newer package deps. Here are the differences from uv pip list between 3.9 and 3.10 versions:

4c4
< click==8.1.8
---
> click==8.2.1
10,11c10
< geopandas==1.0.1
< importlib-metadata==8.7.0
---
> geopandas==1.1.1
13c12
< numpy==2.0.2
---
> numpy==2.2.6
20c19
< pyproj==3.6.1
---
> pyproj==3.7.1
28c27
< shapely==2.0.7
---
> shapely==2.1.1
34d32
< zipp==3.23.0

I tried switching out a few older deps with Python 3.10, but the test still fails. I can't see any easy way to get meaningful traceback info on the error either. The only stderr is "Aborted!".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions