当前位置: 首页>>代码示例>>Python>>正文


Python GangaList.__reversed__方法代码示例

本文整理汇总了Python中Ganga.GPIDev.Lib.GangaList.GangaList.GangaList.__reversed__方法的典型用法代码示例。如果您正苦于以下问题:Python GangaList.__reversed__方法的具体用法?Python GangaList.__reversed__怎么用?Python GangaList.__reversed__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ganga.GPIDev.Lib.GangaList.GangaList.GangaList的用法示例。


在下文中一共展示了GangaList.__reversed__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestGangaList

# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import __reversed__ [as 别名]

#.........这里部分代码省略.........
        assert (self.plain2 < self.plain1) == (
            self.proxied2 < self.proxied1), 'The lists should have the same lt'

        assert (self.proxied1 < self.proxied2) != (
            self.proxied2 < self.proxied1), 'The lt should invert correctly'

    def testMul(self):
        """Test __mul__"""
        assert (self.plain1 * 7) == (self.proxied1 * 7)
        assert isProxy(self.proxied1 * 9)

        for p in self.proxied1:
            assert isProxy(p)

    def testNE(self):
        """Test __ne__"""

        assert self.plain1 != self.plain2
        assert self.proxied1 != self.proxied2, 'Lists should be different'

        assert self.plain1[0:5] != self.plain1[2:7]
        assert self.proxied1[0:5] != self.proxied1[
            2:7], 'Lists should be different'

    def testRMul(self):
        """Test __rmul__"""

        t1 = 5 * self.plain1
        t2 = 5 * self.proxied1

        assert t1 == t2, 'Multiplication should be the same'

    def testReversed(self):
        """Test the __reversed__ feature (new in python 2.4)."""

        from TFile import TFile as tF
        count = len(self.proxied1) - 1
        for i in self.proxied1.__reversed__():
            assert i is self.proxied1[count]
            assert isProxy(i)
            assert isType(i, tF)
            count -= 1

    def testSetItem(self):
        """Test __setitem__"""

        t = TFile(name='foo', subdir='cheese')
        test_index = 7
        self.plain1[test_index] = t
        assert self.plain1[test_index] is t

        self.proxied1[test_index] = t
        assert self.proxied1[test_index] is t
        assert isProxy(self.proxied1[test_index])

    def testSetSliceProxyList(self):

        self.plain1[3:7] = self.plain2[3:7]
        assert self.plain1[3:7] == self.plain2[
            3:7], 'The lists should be equal'
        assert self.plain1[3:7] is not self.plain2[
            3:7], 'The lists should be copies'
        self.plain1[4] = self.plain2[9]
        assert self.plain1[4] != self.plain2[4]

        tmp = self.plain1[2:9]
开发者ID:chrisburr,项目名称:ganga,代码行数:70,代码来源:TestGangaList.py

示例2: TestGangaList

# 需要导入模块: from Ganga.GPIDev.Lib.GangaList.GangaList import GangaList [as 别名]
# 或者: from Ganga.GPIDev.Lib.GangaList.GangaList.GangaList import __reversed__ [as 别名]

#.........这里部分代码省略.........
        """Test __lt__"""

        self.assertEqual(self.plain1 < self.plain2, self.proxied1 < self.proxied2, 'The lists should have the same lt')
        self.assertEqual(self.plain2 < self.plain1, self.proxied2 < self.proxied1, 'The lists should have the same lt')

        self.assertNotEqual(self.proxied1 < self.proxied2, self.proxied2 < self.proxied1, 'The lt should invert correctly')

    def testMul(self):
        """Test __mul__"""
        self.assertEqual((self.plain1 * 7), (self.proxied1 * 7))
        self.assertTrue(isProxy(self.proxied1 * 9))

        for p in self.proxied1:
            self.assertTrue(isProxy(p))

    def testNE(self):
        """Test __ne__"""

        self.assertNotEqual(self.plain1, self.plain2)
        self.assertNotEqual(self.proxied1, self.proxied2, 'Lists should be different')

        self.assertNotEqual(self.plain1[0:5], self.plain1[2:7])
        self.assertNotEqual(self.proxied1[0:5], self.proxied1[2:7], 'Lists should be different')

    def testRMul(self):
        """Test __rmul__"""

        t1 = 5 * self.plain1
        t2 = 5 * self.proxied1

        self.assertEqual(t1, t2, 'Multiplication should be the same')

    def testReversed(self):
        """Test the __reversed__ feature (new in python 2.4)."""

        count = len(self.proxied1) - 1
        for i in self.proxied1.__reversed__():
            self.assertIs(i, self.proxied1[count])
            self.assertTrue(isProxy(i))
            self.assertTrue(isType(i, TFile))
            count -= 1

    def testSetItem(self):
        """Test __setitem__"""

        t = TFile(name='foo', subdir='cheese')
        test_index = 7
        self.plain1[test_index] = t
        self.assertIs(self.plain1[test_index], t)

        self.proxied1[test_index] = t
        self.assertIs(self.proxied1[test_index], t)
        self.assertTrue(isProxy(self.proxied1[test_index]))

    def testSetSliceProxyList(self):

        self.plain1[3:7] = self.plain2[3:7]
        self.assertEqual(self.plain1[3:7], self.plain2[3:7], 'The lists should be equal')
        self.assertIsNot(self.plain1[3:7], self.plain2[3:7], 'The lists should be copies')
        self.plain1[4] = self.plain2[9]
        self.assertNotEqual(self.plain1[4], self.plain2[4])

        tmp = self.plain1[2:9]
        self.assertIsNot(self.plain1[2:9], tmp)

        self.proxied1[3:7] = self.proxied2[3:7]
开发者ID:Erni1619,项目名称:ganga,代码行数:70,代码来源:TestGangaList.py


注:本文中的Ganga.GPIDev.Lib.GangaList.GangaList.GangaList.__reversed__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。