def test_setitem(self): space = self.space w = space.wrap # This should work if test_listobject.py passes l = W_ListObject(space, [w('a'),w('b'),w('c')]) assert space.eq_w(l.getitem(0), w('a')) l.setitem(0, w('d')) assert space.eq_w(l.getitem(0), w('d')) assert isinstance(l.strategy, BytesListStrategy) # IntStrategy to ObjectStrategy l = W_ListObject(space, [w(1),w(2),w(3)]) assert isinstance(l.strategy, IntegerListStrategy) l.setitem(0, w('d')) assert isinstance(l.strategy, ObjectListStrategy) # BytesStrategy to ObjectStrategy l = W_ListObject(space, [w('a'),w('b'),w('c')]) assert isinstance(l.strategy, BytesListStrategy) l.setitem(0, w(2)) assert isinstance(l.strategy, ObjectListStrategy) # UnicodeStrategy to ObjectStrategy l = W_ListObject(space, [w(u'a'),w(u'b'),w(u'c')]) assert isinstance(l.strategy, UnicodeListStrategy) l.setitem(0, w(2)) assert isinstance(l.strategy, ObjectListStrategy) # FloatStrategy to ObjectStrategy l = W_ListObject(space, [w(1.2),w(2.3),w(3.4)]) assert isinstance(l.strategy, FloatListStrategy) l.setitem(0, w("a")) assert isinstance(l.strategy, ObjectListStrategy)
def test_setitem(self): space = self.space w = space.wrap wb = space.newbytes # This should work if test_listobject.py passes l = W_ListObject(space, [w('a'), w('b'), w('c')]) assert space.eq_w(l.getitem(0), w('a')) l.setitem(0, w('d')) assert space.eq_w(l.getitem(0), w('d')) assert isinstance(l.strategy, BytesListStrategy) # IntStrategy to ObjectStrategy l = W_ListObject(space, [w(1), w(2), w(3)]) assert isinstance(l.strategy, IntegerListStrategy) l.setitem(0, w('d')) assert isinstance(l.strategy, ObjectListStrategy) # BytesStrategy to ObjectStrategy l = W_ListObject(space, [wb('a'), wb('b'), wb('c')]) assert isinstance(l.strategy, BytesListStrategy) l.setitem(0, w(2)) assert isinstance(l.strategy, ObjectListStrategy) # UnicodeStrategy to ObjectStrategy l = W_ListObject(space, [w(u'a'), w(u'b'), w(u'c')]) assert isinstance(l.strategy, UnicodeListStrategy) l.setitem(0, w(2)) assert isinstance(l.strategy, ObjectListStrategy) # FloatStrategy to ObjectStrategy l = W_ListObject(space, [w(1.2), w(2.3), w(3.4)]) assert isinstance(l.strategy, FloatListStrategy) l.setitem(0, w("a")) assert isinstance(l.strategy, ObjectListStrategy)
def test_mul_same_strategy_but_different_object(self): l1 = W_ListObject( self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)]) l2 = l1.mul(1) assert self.space.eq_w(l1, l2) l1.setitem(0, self.space.wrap(5)) assert not self.space.eq_w(l1, l2)
def test_setitem(self): # This should work if test_listobject.py passes l = W_ListObject(self.space, [self.space.wrap('a'),self.space.wrap('b'),self.space.wrap('c')]) assert self.space.eq_w(l.getitem(0), self.space.wrap('a')) l.setitem(0, self.space.wrap('d')) assert self.space.eq_w(l.getitem(0), self.space.wrap('d')) assert isinstance(l.strategy, StringListStrategy) # IntStrategy to ObjectStrategy l = W_ListObject(self.space, [self.space.wrap(1),self.space.wrap(2),self.space.wrap(3)]) assert isinstance(l.strategy, IntegerListStrategy) l.setitem(0, self.space.wrap('d')) assert isinstance(l.strategy, ObjectListStrategy) # StringStrategy to ObjectStrategy l = W_ListObject(self.space, [self.space.wrap('a'),self.space.wrap('b'),self.space.wrap('c')]) assert isinstance(l.strategy, StringListStrategy) l.setitem(0, self.space.wrap(2)) assert isinstance(l.strategy, ObjectListStrategy) # FloatStrategy to ObjectStrategy l = W_ListObject(self.space, [self.space.wrap(1.2),self.space.wrap(2.3),self.space.wrap(3.4)]) assert isinstance(l.strategy, FloatListStrategy) l.setitem(0, self.space.wrap("a")) assert isinstance(l.strategy, ObjectListStrategy)
def test_setitem(self): # This should work if test_listobject.py passes l = W_ListObject( self.space, [self.space.wrap('a'), self.space.wrap('b'), self.space.wrap('c')]) assert self.space.eq_w(l.getitem(0), self.space.wrap('a')) l.setitem(0, self.space.wrap('d')) assert self.space.eq_w(l.getitem(0), self.space.wrap('d')) assert isinstance(l.strategy, StringListStrategy) # IntStrategy to ObjectStrategy l = W_ListObject( self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)]) assert isinstance(l.strategy, IntegerListStrategy) l.setitem(0, self.space.wrap('d')) assert isinstance(l.strategy, ObjectListStrategy) # StringStrategy to ObjectStrategy l = W_ListObject( self.space, [self.space.wrap('a'), self.space.wrap('b'), self.space.wrap('c')]) assert isinstance(l.strategy, StringListStrategy) l.setitem(0, self.space.wrap(2)) assert isinstance(l.strategy, ObjectListStrategy) # FloatStrategy to ObjectStrategy l = W_ListObject( self.space, [self.space.wrap(1.2), self.space.wrap(2.3), self.space.wrap(3.4)]) assert isinstance(l.strategy, FloatListStrategy) l.setitem(0, self.space.wrap("a")) assert isinstance(l.strategy, ObjectListStrategy)
def test_mul_same_strategy_but_different_object(self): l1 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)]) l2 = l1.mul(1) assert self.space.eq_w(l1, l2) l1.setitem(0, self.space.wrap(5)) assert not self.space.eq_w(l1, l2)