@@ -102,7 +102,9 @@ part of your geospatial project.
102102- Equality comparisons between Records now also require the fields to be the same (and in the same order).
103103
104104### Development:
105- - Code quality tools run on PyShp
105+ - Code quality tools (Ruff format) run on PyShp
106+ - Network, non-network, or all doctests selectable via command line args
107+ - Network tests made runnable on localhost.
106108
107109## 2.3.1
108110
@@ -1434,24 +1436,61 @@ ESRI White Paper](http://downloads.esri.com/support/whitepapers/ao_/J9749_MultiP
14341436
14351437The testing framework is pytest, and the tests are located in test_shapefile.py.
14361438This includes an extensive set of unit tests of the various pyshp features,
1437- and tests against various input data. Some of the tests that require
1438- internet connectivity will be skipped in offline testing environments.
1439+ and tests against various input data.
14391440In the same folder as README.md and shapefile.py, from the command line run
1440- ```
1441- $ python -m pytest
1441+
1442+ ``` shell
1443+ python -m pytest
14421444```
14431445
14441446Additionally, all the code and examples located in this file, README.md,
14451447is tested and verified with the builtin doctest framework.
14461448A special routine for invoking the doctest is run when calling directly on shapefile.py.
14471449In the same folder as README.md and shapefile.py, from the command line run
1448- ```
1449- $ python shapefile.py
1450+
1451+ ``` shell
1452+ python shapefile.py
14501453```
14511454
14521455Linux/Mac and similar platforms may need to run ` $ dos2unix README.md ` in order
14531456to correct line endings in README.md, if Git has not automatically changed them.
14541457
1458+ ## Network tests
1459+
1460+ Some of the tests and doctests, are intended to test reading shapefiles from
1461+ remote servers, which requires internet connectivity. The pytest tests are marked "network".
1462+ For rapid iteration, in CI, or when developing in offline testing environments, these
1463+ tests can be dealt with in two ways:
1464+ i) by skipping the network tests via :
1465+ ``` shell
1466+ pytest -m " not network"
1467+ ```
1468+ or the doctests via:
1469+ ``` shell
1470+ python shapefile.py -m " not network"
1471+ ```
1472+ or ii) by cloning a repo of the files they download, serving these on localhost in a separate process,
1473+ and running the network tests with the environment variable REPLACE_REMOTE_URLS_WITH_LOCALHOST to ` yes ` :
1474+ Setup a local file server (* ):
1475+ ```
1476+ git clone http://github.com/JamesParrott/PyShp_test_shapefile
1477+ cd PyShp_test_shapefile
1478+ python -m http.server 8000
1479+ ```
1480+ and then:
1481+ ``` bash
1482+ REPLACE_REMOTE_URLS_WITH_LOCALHOST=yes && pytest
1483+ ```
1484+ or the doctests via:
1485+ ``` bash
1486+ REPLACE_REMOTE_URLS_WITH_LOCALHOST=yes && python shapefile.py
1487+ ```
1488+ The network tests alone can also be run (without also running all the tests that don't
1489+ make network requests) using: ` pytest -m network ` (or the doctests using: ` python shapefile.py -m network ` ).
1490+
1491+ (* ) The steps to host the files using Caddy for PYthon 2 are in ./actions/test/action.yml. For reasons as
1492+ yet unknown, shapefile.py's Reader class in Python 2 Pytest, can't connect to a Python 2 SimpleHTTPServer.
1493+
14551494
14561495# Contributors
14571496
0 commit comments