本文整理汇总了Python中Ganga.GPIDev.Lib.GangaList.GangaList.GangaList.index方法的典型用法代码示例。如果您正苦于以下问题:Python GangaList.index方法的具体用法?Python GangaList.index怎么用?Python GangaList.index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ganga.GPIDev.Lib.GangaList.GangaList.GangaList
的用法示例。
在下文中一共展示了GangaList.index方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestGangaList
# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import index [as 别名]
#.........这里部分代码省略.........
self.plain1 + self.proxied2)[-1] == self.proxied2[-1], 'File objects should be equal'
assert (
self.plain1 + self.proxied2)[-1] is self.proxied2[-1], 'File objects should be identical'
def testAddStr(self):
"""Makes sure that only lists can be added."""
try:
[] + ''
assert False, 'Line above should throw a TypeError'
except TypeError:
pass
try:
self.proxied1 + ''
assert False, 'Line above should throw a TypeError'
except TypeError:
pass
def testContains(self):
"""Tests __contains__"""
plist = [addProxy(x) for x in self.plain1]
assert plist == self.proxied1
for p in plist:
assert isProxy(p)
assert p in self.proxied1, 'Proxied list should contain each proxied object'
def testDelItem(self):
"""Test __delitem__"""
for p in [addProxy(x) for x in self.plain1[:]]:
assert isProxy(p)
del self.proxied1[self.proxied1.index(p)]
def testGE(self):
"""Test __ge__"""
assert (self.plain1 >= self.plain2) == (
self.proxied1 >= self.proxied2), 'The lists should have the same ge'
assert (self.plain2 >= self.plain1) == (
self.proxied2 >= self.proxied1), 'The lists should have the same ge'
assert (self.proxied1 >= self.proxied2) != (
self.proxied2 >= self.proxied1), 'The gt should invert correctly'
def testGetItem(self):
"""Test __getitem__"""
for i in range(len(self.proxied1)):
assert isProxy(self.proxied1[i])
def testGetSlice(self):
"""Test __getslice__"""
slices = [(0, 0), (0, len(self.plain1))]
for s in slices:
assert self.plain1[s[0]:s[1]] == self.proxied1[
s[0]:s[1]], 'Slices %s should be the same' % str(s)
t = self.plain1[:]
assert t is not self.plain1, 'Slice should be a copy.'
assert self.plain1[:] is not t
t = self.proxied1[:]
示例2: TestGangaList
# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import index [as 别名]
#.........这里部分代码省略.........
self.assertEqual((self.plain1 + self.proxied2)[-1], self.proxied2[-1], 'File objects should be equal')
self.assertIs((self.plain1 + self.proxied2)[-1], self.proxied2[-1], 'File objects should be identical')
def testAddStr(self):
"""Makes sure that only lists can be added."""
try:
[] + ''
assert False, 'Line above should throw a TypeError'
except TypeError:
pass
try:
self.proxied1 + ''
assert False, 'Line above should throw a TypeError'
except TypeError:
pass
def testContains(self):
"""Tests __contains__"""
plist = [addProxy(x) for x in self.plain1]
self.assertEqual(plist, self.proxied1)
for p in plist:
self.assertTrue(isProxy(p))
self.assertIn(p, self.proxied1, 'Proxied list should contain each proxied object')
def testDelItem(self):
"""Test __delitem__"""
for p in [addProxy(x) for x in self.plain1[:]]:
self.assertTrue(isProxy(p))
del self.proxied1[self.proxied1.index(p)]
def testGE(self):
"""Test __ge__"""
self.assertEqual((self.plain1 >= self.plain2), (self.proxied1 >= self.proxied2), 'The lists should have the same ge')
self.assertEqual((self.plain2 >= self.plain1), (self.proxied2 >= self.proxied1), 'The lists should have the same ge')
self.assertNotEqual((self.proxied1 >= self.proxied2), (self.proxied2 >= self.proxied1), 'The gt should invert correctly')
def testGetItem(self):
"""Test __getitem__"""
for i in range(len(self.proxied1)):
self.assertTrue(isProxy(self.proxied1[i]))
def testGetSlice(self):
"""Test __getslice__"""
slices = [(0, 0), (0, len(self.plain1))]
for s in slices:
self.assertEqual(self.plain1[s[0]:s[1]], self.proxied1[s[0]:s[1]], 'Slices {0} should be the same'.format(s))
t = self.plain1[:]
self.assertIsNot(t, self.plain1, 'Slice should be a copy.')
self.assertIsNot(self.plain1[:], t)
t = self.proxied1[:]
self.assertIsNot(t, self.proxied1, 'Slice should be a copy.')
self.assertIsNot(self.proxied1[:], t)
def testGT(self):