Skip to content

Flakey tests relying on downloads from https://github.com/nvkelso/natural-earth-vector/blob/master/10m_cultural/ne_10m_admin_1_states_provinces #318

@JamesParrott

Description

@JamesParrott

PyShp Version

3.2.1 / latest / all

Python Version

All

Your code

python shapefile.py


or


python -m pytest

Full stacktrace

Example, doctests can fail, when immediately repeated after a successful run

(.venv) C:\Users\...\pyshp>python shapefile.py
Running doctests...
All test passed successfully

(.venv) C:\Users\...\pyshp>python shapefile.py
Running doctests...
**********************************************************************
File "README.md", line 314, in README
Failed example:
    sf = shapefile.Reader("https://github.com/nvkelso/natural-earth-vector/blob/master/110m_cultural/ne_110m_admin_0_tiny_countries.shp?raw=true")
Exception raised:
    Traceback (most recent call last):
      File "C:\Users\...\AppData\Roaming\uv\python\cpython-3.13.0-windows-x86_64-none\Lib\doctest.py", line 1395, in __run
        exec(compile(example.source, filename, "single",
        ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                     compileflags, True), test.globs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<doctest README[8]>", line 1, in <module>
        sf = shapefile.Reader("https://github.com/nvkelso/natural-earth-vector/blob/master/110m_cultural/ne_110m_admin_0_tiny_countries.shp?raw=true")
      File "C:\Users\...\pyshp\shapefile.py", line 1091, in __init__
        raise ShapefileException(
            "No shp or dbf file found at url: %s" % path
        )
    shapefile.ShapefileException: No shp or dbf file found at url: https://github.com/nvkelso/natural-earth-vector/blob/master/110m_cultural/ne_110m_admin_0_tiny_countries.shp?raw=true
**********************************************************************
File "README.md", line 1187, in README
Failed example:
    for shape in sf.iterShapes():
        # do something here
        pass
Exception raised:
    Traceback (most recent call last):
      File "C:\Users\...\AppData\Roaming\uv\python\cpython-3.13.0-windows-x86_64-none\Lib\doctest.py", line 1395, in __run
        exec(compile(example.source, filename, "single",
        ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                     compileflags, True), test.globs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<doctest README[221]>", line 1, in <module>
        for shape in sf.iterShapes():
                     ~~~~~~~~~~~~~^^
      File "C:\Users\...\pyshp\shapefile.py", line 1548, in iterShapes
        shp = self.__getFileObj(self.shp)
      File "C:\Users\...\pyshp\shapefile.py", line 1319, in __getFileObj
        raise ShapefileException(
            "Shapefile Reader requires a shapefile or file-like object."
        )
    shapefile.ShapefileException: Shapefile Reader requires a shapefile or file-like object.
**********************************************************************
File "README.md", line 1195, in README
Failed example:
    for shapeRec in sf.iterShapeRecords():
        # do something here
        pass
Exception raised:
    Traceback (most recent call last):
      File "C:\Users\...\AppData\Roaming\uv\python\cpython-3.13.0-windows-x86_64-none\Lib\doctest.py", line 1395, in __run
        exec(compile(example.source, filename, "single",
        ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                     compileflags, True), test.globs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<doctest README[223]>", line 1, in <module>
        for shapeRec in sf.iterShapeRecords():
                        ~~~~~~~~~~~~~~~~~~~^^
      File "C:\Users\...\pyshp\shapefile.py", line 1889, in iterShapeRecords
        for shape, record in izip(
                             ~~~~^
            self.iterShapes(), self.iterRecords(fields=fields)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        ):
        ^
      File "C:\Users\...\pyshp\shapefile.py", line 1548, in iterShapes
        shp = self.__getFileObj(self.shp)
      File "C:\Users\...\pyshp\shapefile.py", line 1319, in __getFileObj
        raise ShapefileException(
            "Shapefile Reader requires a shapefile or file-like object."
        )
    shapefile.ShapefileException: Shapefile Reader requires a shapefile or file-like object.
**********************************************************************
File "README.md", line 1199, in README
Failed example:
    for shapeRec in sf: # same as iterShapeRecords()
        # do something here
        pass
Exception raised:
    Traceback (most recent call last):
      File "C:\Users\...\AppData\Roaming\uv\python\cpython-3.13.0-windows-x86_64-none\Lib\doctest.py", line 1395, in __run
        exec(compile(example.source, filename, "single",
        ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                     compileflags, True), test.globs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<doctest README[224]>", line 1, in <module>
        for shapeRec in sf: # same as iterShapeRecords()
                        ^^
      File "C:\Users\...\pyshp\shapefile.py", line 1222, in __iter__
        for shaperec in self.iterShapeRecords():
                        ~~~~~~~~~~~~~~~~~~~~~^^
      File "C:\Users\...\pyshp\shapefile.py", line 1889, in iterShapeRecords
        for shape, record in izip(
                             ~~~~^
            self.iterShapes(), self.iterRecords(fields=fields)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        ):
        ^
      File "C:\Users\...\pyshp\shapefile.py", line 1548, in iterShapes
        shp = self.__getFileObj(self.shp)
      File "C:\Users\...\pyshp\shapefile.py", line 1319, in __getFileObj
        raise ShapefileException(
            "Shapefile Reader requires a shapefile or file-like object."
        )
    shapefile.ShapefileException: Shapefile Reader requires a shapefile or file-like object.
**********************************************************************
File "README.md", line 1222, in README
Failed example:
    for rec in sf.iterRecords(fields=[filter_field]):
        if rec[filter_field] == filter_value:
                # load full record and shape
                shapeRec = sf.shapeRecord(rec.oid)
                shapeRec.record["name"]
Exception raised:
    Traceback (most recent call last):
      File "C:\Users\...\AppData\Roaming\uv\python\cpython-3.13.0-windows-x86_64-none\Lib\doctest.py", line 1395, in __run
        exec(compile(example.source, filename, "single",
        ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                     compileflags, True), test.globs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<doctest README[230]>", line 4, in <module>
        shapeRec = sf.shapeRecord(rec.oid)
      File "C:\Users\...\pyshp\shapefile.py", line 1864, in shapeRecord
        shape = self.shape(i, bbox=bbox)
      File "C:\Users\...\pyshp\shapefile.py", line 1498, in shape
        shp = self.__getFileObj(self.shp)
      File "C:\Users\...\pyshp\shapefile.py", line 1319, in __getFileObj
        raise ShapefileException(
            "Shapefile Reader requires a shapefile or file-like object."
        )
    shapefile.ShapefileException: Shapefile Reader requires a shapefile or file-like object.
**********************************************************************
File "README.md", line 1243, in README
Failed example:
    for shapeRec in sf.iterShapeRecords(bbox=bbox, fields=fields):
        shapeRec.record
Exception raised:
    Traceback (most recent call last):
      File "C:\Users\...\AppData\Roaming\uv\python\cpython-3.13.0-windows-x86_64-none\Lib\doctest.py", line 1395, in __run
        exec(compile(example.source, filename, "single",
        ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                     compileflags, True), test.globs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<doctest README[233]>", line 1, in <module>
        for shapeRec in sf.iterShapeRecords(bbox=bbox, fields=fields):
                        ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\...\pyshp\shapefile.py", line 1899, in iterShapeRecords
        for shape in self.iterShapes(bbox=bbox):
                     ~~~~~~~~~~~~~~~^^^^^^^^^^^
      File "C:\Users\...\pyshp\shapefile.py", line 1548, in iterShapes
        shp = self.__getFileObj(self.shp)
      File "C:\Users\...\pyshp\shapefile.py", line 1319, in __getFileObj
        raise ShapefileException(
            "Shapefile Reader requires a shapefile or file-like object."
        )
    shapefile.ShapefileException: Shapefile Reader requires a shapefile or file-like object.
**********************************************************************
1 item had failures:
   6 of 269 in README
***Test Failed*** 6 failures.

Other notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions