def test_sd_setitems(self): r = sorteddict() r['b'] = 1 r['c'] = 2 r['d'] = 3 r['f'] = 5 r['g'] = 6 r['h'] = 7 r['i'] = 8 r['a'] = 0 r['j'] = 9 r['l'] = 11 r['k'] = 10 r['m'] = 12 r['n'] = 13 r['o'] = 14 r['p'] = 15 r['q'] = 16 r['s'] = 18 r['v'] = 21 r['w'] = 22 r['x'] = 23 r['y'] = 24 r['z'] = 25 r['e'] = 4 r['r'] = 17 r['t'] = 19 r['u'] = 20 assert r == self.z
def test_sd_ass_consequitive_slice(self): r = sorteddict(self.z) if not self.nopytest: py.test.raises( TypeError, "r[10:15] = ordereddict([(1, 0), (2, 1), (3, 2), (4, 24), (5, 25)])" )
def test_sd_slice(self): r = sorteddict(self.z) #print r y = r[3:6] #print y assert y['d'] == 3 assert y['e'] == 4 assert y['f'] == 5
def test_sd_copy(self): x1 = sorteddict(self.z) x = x1.copy() assert len(x) == 26 assert x['c'] == 2 x['c'] = 4 assert self.x['c'] == 3 assert x['c'] == 4
def test_sd_pickle(self): fname = 'tmpdata.pkl' r = sorteddict(self.z) fp = open(fname, 'wb') cPickle.dump(r, fp) fp.close() s = cPickle.load(open(fname, 'rb')) assert s == r s['k'] = 10 assert s == self.z os.remove(fname)
def test_sorted_from_ordered(self): i = self.z.items(reverse=True) random.shuffle(i) i = ordereddict(i) sd = sorteddict(i) assert sd == self.z
def test_sd_rename(self): x = sorteddict(self.x) if not self.nopytest: py.test.raises(TypeError, "x.rename('c', 'caaa')")
def test_sd_init_from_seq(self): r = sorteddict((('j', 9),('g', 6),('i', 8),('h', 7), ('f', 5))) assert r == self.part
def test_sd_del_non_consequitive_slice(self): r = sorteddict(self.z) if not self.nopytest: py.test.raises(TypeError, "del r[4:24:2]")
def test_sd_init_from_seq(self): r = sorteddict((('j', 9), ('g', 6), ('i', 8), ('h', 7), ('f', 5))) assert r == self.part
def test_sd_lower(self): r = sorteddict(self.upperlower) assert r != self.upperlower assert r.index('a') == 2 rl = sorteddict(self.upperlower, key=string.lower) assert rl == self.upperlower
def test_sd_ass_non_consequitive_slice(self): r = sorteddict(self.z) if not self.nopytest: py.test.raises(TypeError, "r[10:15:2] = ordereddict([(1, 0), (2, 1), (3, 2),])")