File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -183,6 +183,17 @@ def test_mappingness(self):
183183 assert_equal (hdr .get (keys [0 ]), vals [0 ])
184184 assert_equal (hdr .get (keys [0 ], 'default' ), vals [0 ])
185185
186+ # make sure .get returns values which evaluate to False. We have to
187+ # use a different falsy value depending on the data type of the first
188+ # header field.
189+ falsyval = 0 if np .issubdtype (hdr_dt [0 ], np .number ) else b''
190+
191+ hdr [keys [0 ]] = falsyval
192+ assert_equal (hdr [keys [0 ]], falsyval )
193+ assert_equal (hdr .get (keys [0 ]), falsyval )
194+ assert_equal (hdr .get (keys [0 ], - 1 ), falsyval )
195+
196+
186197 def test_endianness_ro (self ):
187198 # endianness is a read only property
188199 ''' Its use in initialization tested in the init tests.
Original file line number Diff line number Diff line change @@ -343,7 +343,7 @@ def items(self):
343343
344344 def get (self , k , d = None ):
345345 ''' Return value for the key k if present or d otherwise'''
346- return ( k in self .keys ()) and self . _structarr [ k ] or d
346+ return self . _structarr [ k ] if k in self .keys () else d
347347
348348 def check_fix (self , logger = None , error_level = None ):
349349 ''' Check structured data with checks
You can’t perform that action at this time.
0 commit comments