Skip to content

Commit

Permalink
Added test case for null string
Browse files Browse the repository at this point in the history
Added fix to check to see if __iter__ was not a string, which was causing a failure
  • Loading branch information
srp3rd committed Aug 9, 2016
1 parent a28b38a commit 8d51941
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/lsst/daf/base/baseLib.i
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def _guessIntegerType(container, name, value):

def _propertyContainerSet(container, name, value, typeMenu, *args):
"""Set a single Python value of unknown type"""
if hasattr(value, "__iter__"):
if hasattr(value, "__iter__") and not isinstance(value, str):
exemplar = value[0]
else:
exemplar = value
Expand Down
2 changes: 2 additions & 0 deletions tests/PropertySet_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def testScalar(self):
ps.setString("string", "bar")
ps.set("int2", 2009)
ps.set("dt", dafBase.DateTime("20090402T072639.314159265Z"))
ps.set("blank", "")

self.assertEqual(ps.typeOf("bool"), dafBase.PropertySet.TYPE_Bool)
self.assertEqual(ps.getBool("bool"), True)
Expand All @@ -71,6 +72,7 @@ def testScalar(self):
self.assertEqual(ps.get("int2"), 2009)
self.assertEqual(ps.typeOf("dt"), dafBase.PropertySet.TYPE_DateTime)
self.assertEqual(ps.getDateTime("dt").nsecs(), long(1238657233314159265))
self.assertEqual(ps.getString("blank"), "")

def testNumPyScalars(self):
"""Test that we can also pass NumPy array scalars to PropertySet setters.
Expand Down

0 comments on commit 8d51941

Please sign in to comment.