@@ -99,9 +99,9 @@ def test_brackets(self):
9999 assert_equals (0 , vals [0 ][0 ])
100100 assert_true (array_equal (self .ary1 , vals [0 ][1 ]))
101101
102- assert_raises ( KeyError , self .images . __getitem__ , 2 ) # equiv: self.images [2]
102+ assert_is_none ( self .images [2 ])
103103
104- assert_raises ( IndexError , self .images . __getitem__ , slice ( 2 , 3 )) # equiv: self.images [2:3]
104+ assert_equals ([] , self .images [2 :3 ])
105105
106106
107107class TestSeriesGetters (PySparkTestCase ):
@@ -250,11 +250,8 @@ def test_brackets(self):
250250 assert_true (array_equal (self .dataLocal [0 ][1 ], vals [0 ][1 ]))
251251 assert_true (array_equal (self .dataLocal [1 ][1 ], vals [1 ][1 ]))
252252
253- # trying to getitem a key that doesn't exist raises KeyError
254- # this differs from `get` behavior but is consistent with python dict
255- # see object.__getitem__ in https://docs.python.org/2/reference/datamodel.html
256- assert_raises (KeyError , self .series .__getitem__ , (25 , 17 )) # equiv: self.series[(25, 17)]
253+ # trying to getitem a key that doesn't exist returns None
254+ assert_is_none (self .series [(25 , 17 )])
257255
258- # passing a range that is completely out of bounds throws IndexError
259- # note that if a range is only partly out of bounds, it will return what elements the slice does include
260- assert_raises (IndexError , self .series .__getitem__ , [slice (2 , 3 ), slice (None )]) # series[2:3,:]
256+ # passing a range that is completely out of bounds returns []
257+ assert_equals ([], self .series [2 :3 , :])
0 commit comments