Skip to content

Commit

Permalink
Change pytest tests to handle empty dbf fields
Browse files Browse the repository at this point in the history
  • Loading branch information
karimbahgat committed Aug 9, 2020
1 parent 70c15e2 commit e0d4365
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions shapefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ def __init__(self, *args, **kwargs):
self.dbf.seek(0)
except (NameError, io.UnsupportedOperation):
self.dbf = io.BytesIO(self.dbf.read())
if self.shp or self.dbf:
if self.shp or self.dbf:
self.load()
else:
raise ShapefileException("Shapefile Reader requires a shapefile or file-like object.")
Expand Down Expand Up @@ -1670,7 +1670,7 @@ def record(self, *recordList, **recordDict):
"""Creates a dbf attribute record. You can submit either a sequence of
field values or keyword arguments of field names and values. Before
adding records you must add fields for the record values using the
fields() method. If the record values exceed the number of fields the
field() method. If the record values exceed the number of fields the
extra ones won't be added. In the case of using keyword arguments to specify
field/value pairs only fields matching the already registered fields
will be added."""
Expand Down
6 changes: 3 additions & 3 deletions test_shapefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def test_write_dbf_only(tmpdir):
"""
filename = tmpdir.join("test.dbf").strpath
with shapefile.Writer(dbf=filename) as writer:
pass
writer.field('field1', 'C') # required to create a valid dbf file

# assert test.dbf exists
assert os.path.exists(filename)
Expand All @@ -247,7 +247,7 @@ def test_write_default_shp_shx_dbf(tmpdir):
"""
filename = tmpdir.join("test").strpath
with shapefile.Writer(filename) as writer:
pass
writer.field('field1', 'C') # required to create a valid dbf file

# assert shp, shx, dbf files exist
assert os.path.exists(filename + ".shp")
Expand All @@ -264,7 +264,7 @@ def test_write_shapefile_extension_ignored(tmpdir):
ext = ".abc"
filename = tmpdir.join(base + ext).strpath
with shapefile.Writer(filename) as writer:
pass
writer.field('field1', 'C') # required to create a valid dbf file

# assert shp, shx, dbf files exist
basepath = tmpdir.join(base).strpath
Expand Down

0 comments on commit e0d4365

Please sign in to comment.