Skip to content

test_reader_url fails #317

@schwehr

Description

@schwehr

PyShp Version

HEAD

Python Version

Python 3.12.9

Your code

No changes to the code

git checkout master
git pull
virtualenv .venv
source .venv/bin/activate
pip install -e .
pip install pre-commit
pre-commit install
pre-commit run --all-files
pip install --upgrade pytest
python -m pytest

Full stacktrace

platform linux -- Python 3.12.9, pytest-8.4.1, pluggy-1.6.0
rootdir: /home/schwehr/src/pyshp
configfile: pytest.ini
collected 100 items                                                                                                                                                   

test_shapefile.py ..................F.................................................................................                                          [100%]

============================================================================== FAILURES ===============================================================================
___________________________________________________________________________ test_reader_url ___________________________________________________________________________

    @pytest.mark.network
    def test_reader_url():
        """
        Assert that Reader can open shapefiles from a url.
        """
        # test with extension
        url = "https://github.com/nvkelso/natural-earth-vector/blob/master/110m_cultural/ne_110m_admin_0_tiny_countries.shp?raw=true"
        with shapefile.Reader(url) as sf:
            for __recShape in sf.iterShapeRecords():
                pass
        assert sf.shp.closed is sf.shx.closed is sf.dbf.closed is True
    
        # test without extension
        url = "https://github.com/nvkelso/natural-earth-vector/blob/master/110m_cultural/ne_110m_admin_0_tiny_countries?raw=true"
        with shapefile.Reader(url) as sf:
            for __recShape in sf.iterShapeRecords():
                pass
            assert len(sf) > 0
>       assert sf.shp.closed is sf.shx.closed is sf.dbf.closed is True
                                ^^^^^^^^^^^^^
E       AttributeError: 'NoneType' object has no attribute 'closed'

test_shapefile.py:503: AttributeError
======================================================================= short test summary info =======================================================================
FAILED test_shapefile.py::test_reader_url - AttributeError: 'NoneType' object has no attribute 'closed'
============================================================== 1 failed, 99 passed in 173.49s (0:02:53) ===============================================================

Other notes

This works and fetches a file:

https://github.com/nvkelso/natural-earth-vector/blob/master/110m_cultural/ne_110m_admin_0_tiny_countries.shp?raw=true

This url gives a 404. Was the code supposed to add the .shp?

https://github.com/nvkelso/natural-earth-vector/blob/master/110m_cultural/ne_110m_admin_0_tiny_countries?raw=true

natural-earth-vector/110m_cultural
/ne_110m_admin_0_tiny_countries/

404 - page not found

The master branch of natural-earth-vector does not contain the path 110m_cultural/ne_110m_admin_0_tiny_countries.

I don't see anything obvious in the code outside of the writer that adds .shp

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions