Skip to content

Test improvements #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# test files
shapefiles/test/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject

# Visual Studio project settings
*.pyproj
*.sln
*.suo
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
sudo: false

addons:
apt:
packages:
- dos2unix

language: python

python:
- "2.6"
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"


install:
- dos2unix README.txt
- pip install .

script: python shapefile.py
3 changes: 2 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,9 @@ The blockgroup key and population count:
There is also an iterShapeRecords() method to iterate through large files:

>>> shapeRecs = sf.iterShapeRecords()
>>> for shape, rec in shapeRecs:
>>> for shapeRec in shapeRecs:
... # do something here
... pass

Writing Shapefiles
++++++++++++++++++
Expand Down
18 changes: 15 additions & 3 deletions shapefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,10 +1187,20 @@ def __fieldNorm(self, fieldName):
fieldName.replace(' ', '_')

# Begin Testing
def test():
def test(verbosity):
import doctest
doctest.NORMALIZE_WHITESPACE = 1
doctest.testfile("README.txt", verbose=1)
existing_files = set(os.listdir('.'))
if verbosity == 0:
print('Running doctests...')
failure_count, test_count = doctest.testfile("README.txt", verbose=verbosity)
temp_files = set(os.listdir('.')) - existing_files
for filename in temp_files:
if not os.path.isdir(filename):
os.unlink(filename)
if verbosity == 0 and failure_count == 0:
print('All test passed successfully')
return failure_count

if __name__ == "__main__":
"""
Expand All @@ -1199,4 +1209,6 @@ def test():
testing libraries but for now unit testing is done using what's available in
2.3.
"""
test()
failure_count = test(0)
sys.exit(failure_count)

Binary file removed shapefiles/test/MyPolyZ.dbf
Binary file not shown.
Binary file removed shapefiles/test/MyPolyZ.shp
Binary file not shown.
Binary file removed shapefiles/test/MyPolyZ.shx
Binary file not shown.
Binary file removed shapefiles/test/NullTest.dbf
Binary file not shown.
Binary file removed shapefiles/test/NullTest.shp
Binary file not shown.
Binary file removed shapefiles/test/NullTest.shx
Binary file not shown.