diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..923d7ab8 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..a75882dd --- /dev/null +++ b/.travis.yml @@ -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 diff --git a/README.txt b/README.txt index df8014f5..ffbe4c3e 100644 --- a/README.txt +++ b/README.txt @@ -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 ++++++++++++++++++ diff --git a/shapefile.py b/shapefile.py index d23f393f..4ee82a30 100644 --- a/shapefile.py +++ b/shapefile.py @@ -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__": """ @@ -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) + diff --git a/shapefiles/test/MyPolyZ.dbf b/shapefiles/test/MyPolyZ.dbf deleted file mode 100644 index 54a50dbb..00000000 Binary files a/shapefiles/test/MyPolyZ.dbf and /dev/null differ diff --git a/shapefiles/test/MyPolyZ.shp b/shapefiles/test/MyPolyZ.shp deleted file mode 100644 index 1651f327..00000000 Binary files a/shapefiles/test/MyPolyZ.shp and /dev/null differ diff --git a/shapefiles/test/MyPolyZ.shx b/shapefiles/test/MyPolyZ.shx deleted file mode 100644 index 62de3220..00000000 Binary files a/shapefiles/test/MyPolyZ.shx and /dev/null differ diff --git a/shapefiles/test/NullTest.dbf b/shapefiles/test/NullTest.dbf deleted file mode 100644 index 84f8aa63..00000000 Binary files a/shapefiles/test/NullTest.dbf and /dev/null differ diff --git a/shapefiles/test/NullTest.shp b/shapefiles/test/NullTest.shp deleted file mode 100644 index 216fedaa..00000000 Binary files a/shapefiles/test/NullTest.shp and /dev/null differ diff --git a/shapefiles/test/NullTest.shx b/shapefiles/test/NullTest.shx deleted file mode 100644 index b00b9a80..00000000 Binary files a/shapefiles/test/NullTest.shx and /dev/null differ