本文整理汇总了Python中Ganga.GPIDev.Lib.GangaList.GangaList.GangaList.insert方法的典型用法代码示例。如果您正苦于以下问题:Python GangaList.insert方法的具体用法?Python GangaList.insert怎么用?Python GangaList.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ganga.GPIDev.Lib.GangaList.GangaList.GangaList
的用法示例。
在下文中一共展示了GangaList.insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestGangaList
# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import insert [as 别名]
#.........这里部分代码省略.........
def testAppend(self):
t = addProxy(TFile(name='foo'))
self.plain1.append(t)
assert self.plain1[-1] == t
assert self.plain1.pop() == t
self.proxied1.append(t)
assert self.proxied1[-1] == t
assert self.proxied1[-1] is t, 'Identity Test'
assert isProxy(self.proxied1[-1]), 'Make sure we get back a proxy'
assert self.proxied1.pop() == t
def testExtend(self):
t1 = [self._makeRandomTFile() for _ in xrange(10)]
self.plain1.extend(t1)
self.proxied1.extend(t1)
assert self.plain1 == self.proxied1, 'Lists should be the same'
t2 = self.proxied1[4:7]
assert isProxy(t2)
from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList as glist
assert isType(t2, glist)
self.plain1.extend(t2)
self.proxied1.extend(t2)
assert self.plain1 == self.proxied1, 'Lists should be the same'
def testIndex(self):
t = addProxy(TFile(name='foo'))
self.proxied1.insert(8, t)
assert self.proxied1[8] == t
assert self.proxied1.index(t) == 8
def testInsert(self):
t = addProxy(TFile(name='foo'))
self.proxied1.insert(8, t)
assert self.proxied1[8] == t
def testPop(self):
list_len = len(self.proxied1)
t = self.proxied1[-1]
r = self.proxied1.pop()
assert t == r
assert t is r
assert len(self.proxied1) == list_len - 1
assert t not in self.proxied1
assert t._impl not in self.proxied1._impl
t = self.proxied1[6]
r = self.proxied1.pop(6)
assert t == r
assert t is r
assert len(self.proxied1) == list_len - 2
assert t not in self.proxied1
assert t._impl not in self.proxied1._impl
def testRemove(self):
t = addProxy(TFile(name='bar'))
self.proxied1.insert(7, t)
list_len = len(self.proxied1)
self.proxied1.remove(t)
assert len(self.proxied1) == list_len - 1
assert t not in self.proxied1
assert t._impl not in self.proxied1._impl
def testIter(self):
from TFile import TFile as tF
count = 0
for f in self.proxied1:
count += 1
assert isProxy(f)
assert isType(f, tF)
assert count == len(self.proxied1), 'Must visit every member'
def testCmp(self):
assert cmp(self.proxied1, self.proxied2) == cmp(
self.plain1, self.plain2)
def testHash(self):
try:
hash(int(self.proxied1))
assert False, 'Lists are not hashable'
except TypeError:
pass
示例2: TestGangaList
# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import insert [as 别名]
#.........这里部分代码省略.........
tmp = self.proxied1[2:9]
self.assertIsNot(self.proxied1[2:9], tmp)
def testAppend(self):
t = TFile(name='foo')
self.plain1.append(t)
self.assertEqual(self.plain1[-1], t)
self.assertEqual(self.plain1.pop(), t)
self.proxied1.append(t)
self.assertEqual(self.proxied1[-1], t)
self.assertIs(self.proxied1[-1], t, 'Identity Test')
self.assertTrue(isProxy(self.proxied1[-1]), 'Make sure we get back a proxy')
self.assertEqual(self.proxied1.pop(), t)
def testExtend(self):
t1 = [self._makeRandomTFile() for _ in xrange(10)]
self.plain1.extend(t1)
self.proxied1.extend(t1)
self.assertEqual(self.plain1, self.proxied1, 'Lists should be the same')
t2 = self.proxied1[4:7]
self.assertTrue(isProxy(t2))
from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList as glist
self.assertTrue(isType(t2, glist))
self.plain1.extend(t2)
self.proxied1.extend(t2)
self.assertEqual(self.plain1, self.proxied1, 'Lists should be the same')
def testIndex(self):
t = TFile(name='foo')
self.proxied1.insert(8, t)
self.assertEqual(self.proxied1[8], t)
self.assertEqual(self.proxied1.index(t), 8)
def testInsert(self):
t = TFile(name='foo')
self.proxied1.insert(8, t)
self.assertEqual(self.proxied1[8], t)
def testPop(self):
list_len = len(self.proxied1)
t = self.proxied1[-1]
r = self.proxied1.pop()
self.assertEqual(t, r)
self.assertIs(t, r)
self.assertEqual(len(self.proxied1), list_len - 1)
self.assertNotIn(t, self.proxied1)
self.assertNotIn(t._impl, self.proxied1._impl)
t = self.proxied1[6]
r = self.proxied1.pop(6)
self.assertEqual(t, r)
self.assertIs(t, r)
self.assertEqual(len(self.proxied1), list_len - 2)
self.assertNotIn(t, self.proxied1)
self.assertNotIn(t._impl, self.proxied1._impl)
def testRemove(self):
t = TFile(name='bar')
self.proxied1.insert(7, t)
list_len = len(self.proxied1)
self.proxied1.remove(t)
self.assertEqual(len(self.proxied1), list_len - 1)
self.assertNotIn(t, self.proxied1)
self.assertNotIn(t._impl, self.proxied1._impl)
def testIter(self):
count = 0
for f in self.proxied1:
count += 1
self.assertTrue(isProxy(f))
self.assertTrue(isType(f, TFile))
self.assertEqual(count, len(self.proxied1), 'Must visit every member')
def testCmp(self):
self.assertEqual(cmp(self.proxied1, self.proxied2), cmp(self.plain1, self.plain2))
def testHash(self):
try:
hash(int(self.proxied1))
assert False, 'Lists are not hashable'
except TypeError:
pass