Skip to content

Commit 6e1a2a0

Browse files
authored
Merge pull request #329 from JamesParrott/pyshp-3.0.0-alpha
Pyshp 3.0.0 alpha
2 parents 21032c8 + 2ba7f42 commit 6e1a2a0

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed

.github/actions/test/action.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,6 @@ runs:
6666
echo "HTTP_SERVER_PID=$!" >> $GITHUB_ENV
6767
sleep 4 # give server time to start
6868
69-
- name: Doctests
70-
shell: bash
71-
working-directory: ${{ inputs.pyshp_repo_directory }}
72-
env:
73-
REPLACE_REMOTE_URLS_WITH_LOCALHOST: ${{ inputs.replace_remote_urls_with_localhost }}
74-
run: python shapefile.py ${{ inputs.extra_args }}
75-
76-
7769
- name: Download wheel and sdist (built in previous jobs)
7870
uses: actions/download-artifact@v4
7971
with:
@@ -87,6 +79,13 @@ runs:
8779
WHEEL_NAME=$(ls pyshp-*py3-none-any.whl)
8880
python -m pip install $WHEEL_NAME[test]
8981
82+
- name: Doctests
83+
shell: bash
84+
working-directory: ${{ inputs.pyshp_repo_directory }}
85+
env:
86+
REPLACE_REMOTE_URLS_WITH_LOCALHOST: ${{ inputs.replace_remote_urls_with_localhost }}
87+
run: python test_shapefile.py ${{ inputs.extra_args }}
88+
9089
- name: Show Python and Pytest versions for logs.
9190
shell: bash
9291
run: |

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ ESRI White Paper](http://downloads.esri.com/support/whitepapers/ao_/J9749_MultiP
14461446
The testing framework is pytest, and the tests are located in test_shapefile.py.
14471447
This includes an extensive set of unit tests of the various pyshp features,
14481448
and tests against various input data.
1449-
In the same folder as README.md and shapefile.py, from the command line run
1449+
In the same folder as README.md and shapefile.py, from the command line run:
14501450

14511451
```shell
14521452
python -m pytest
@@ -1455,12 +1455,21 @@ python -m pytest
14551455
Additionally, all the code and examples located in this file, README.md,
14561456
is tested and verified with the builtin doctest framework.
14571457
A special routine for invoking the doctest is run when calling directly on shapefile.py.
1458-
In the same folder as README.md and shapefile.py, from the command line run
1458+
In the same folder as README.md and shapefile.py, from the command line run:
14591459

14601460
```shell
14611461
python shapefile.py
14621462
```
14631463

1464+
This tests the code inside shapefile.py itself. To test an installed PyShp wheel against
1465+
the doctests, the same special routine can be invoked (in an env with the wheel and pytest
1466+
installed) from the test file:
1467+
1468+
1469+
```shell
1470+
python test_shapefile.py
1471+
```
1472+
14641473
Linux/Mac and similar platforms may need to run `$ dos2unix README.md` in order
14651474
to correct line endings in README.md, if Git has not automatically changed them.
14661475

@@ -1497,8 +1506,6 @@ REPLACE_REMOTE_URLS_WITH_LOCALHOST=yes && python shapefile.py
14971506
The network tests alone can also be run (without also running all the tests that don't
14981507
make network requests) using: `pytest -m network` (or the doctests using: `python shapefile.py -m network`).
14991508

1500-
(*) The steps to host the files using Caddy for PYthon 2 are in ./actions/test/action.yml. For reasons as
1501-
yet unknown, shapefile.py's Reader class in Python 2 Pytest, can't connect to a Python 2 SimpleHTTPServer.
15021509

15031510

15041511
# Contributors

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[pytest]
22
markers =
33
network: marks tests requiring network access
4+
slow: marks other tests that cause bottlenecks

shapefile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2979,10 +2979,14 @@ def summarize(self):
29792979
return failure_count
29802980

29812981

2982-
if __name__ == "__main__":
2982+
def main():
29832983
"""
29842984
Doctests are contained in the file 'README.md', and are tested using the built-in
29852985
testing libraries.
29862986
"""
29872987
failure_count = _test()
29882988
sys.exit(failure_count)
2989+
2990+
2991+
if __name__ == "__main__":
2992+
main()

test_shapefile.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ def test_record_oid():
982982
assert shaperec.record.oid == i
983983

984984

985+
@pytest.mark.slow
985986
def test_iterRecords_start_stop():
986987
"""
987988
Assert that Reader.iterRecords(start, stop)
@@ -1850,3 +1851,9 @@ def test_write_empty_shapefile(tmpdir, shape_type):
18501851
assert len(r.records()) == 0
18511852
# test shapes are empty
18521853
assert len(r.shapes()) == 0
1854+
1855+
1856+
# This allows a PyShp wheel installed in the env to be tested
1857+
# against the doctests.
1858+
if __name__ == "__main__":
1859+
shapefile.main()

0 commit comments

Comments
 (0)