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


Python IndexedContainer.removeItem方法代码示例

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


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

示例1: testItemSetChangeListeners

# 需要导入模块: from muntjac.data.util.indexed_container import IndexedContainer [as 别名]
# 或者: from muntjac.data.util.indexed_container.IndexedContainer import removeItem [as 别名]
    def testItemSetChangeListeners(self):
        container = IndexedContainer()
        counter = ItemSetChangeCounter()
        container.addListener(counter)

        id1 = 'id1'
        id2 = 'id2'
        id3 = 'id3'

        self.initializeContainer(container)
        counter.reset()
        container.addItem()
        counter.assertOnce()
        container.addItem(id1)
        counter.assertOnce()

        self.initializeContainer(container)
        counter.reset()
        container.addItemAt(0)
        counter.assertOnce()
        container.addItemAt(0, id1)
        counter.assertOnce()
        container.addItemAt(0, id2)
        counter.assertOnce()
        container.addItemAt(len(container), id3)
        counter.assertOnce()
        # no notification if already in container
        container.addItemAt(0, id1)
        counter.assertNone()

        self.initializeContainer(container)
        counter.reset()
        container.addItemAfter(None)
        counter.assertOnce()
        container.addItemAfter(None, id1)
        counter.assertOnce()
        container.addItemAfter(id1)
        counter.assertOnce()
        container.addItemAfter(id1, id2)
        counter.assertOnce()
        container.addItemAfter(container.firstItemId())
        counter.assertOnce()
        container.addItemAfter(container.lastItemId())
        counter.assertOnce()
        container.addItemAfter(container.lastItemId(), id3)
        counter.assertOnce()
        # no notification if already in container
        container.addItemAfter(0, id1)
        counter.assertNone()

        self.initializeContainer(container)
        counter.reset()
        container.removeItem(self.sampleData[0])
        counter.assertOnce()

        self.initializeContainer(container)
        counter.reset()
        # no notification for removing a non-existing item
        container.removeItem(id1)
        counter.assertNone()

        self.initializeContainer(container)
        counter.reset()
        container.removeAllItems()
        counter.assertOnce()
        # already empty
        container.removeAllItems()
        counter.assertNone()
开发者ID:kranthikumar,项目名称:muntjac,代码行数:70,代码来源:indexed_container_test.py

示例2: testItemSetChangeListenersFiltering

# 需要导入模块: from muntjac.data.util.indexed_container import IndexedContainer [as 别名]
# 或者: from muntjac.data.util.indexed_container.IndexedContainer import removeItem [as 别名]

#.........这里部分代码省略.........
        counter.assertNone()
        item = container.addItemAt(len(container), id2)
        counter.assertNone()

        self.initializeContainer(container)
        counter.reset()
        # passes filter
        item = container.addItemAfter(None, id1)
        counter.assertNone()
        item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id1)
        counter.assertOnce()
        item = container.addItemAfter(container.lastItemId(), id2)
        counter.assertNone()
        item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id2)
        counter.assertOnce()
        # passes filter but already in the container
        item = container.addItemAfter(None, id1)
        counter.assertNone()
        item = container.addItemAfter(container.lastItemId(), id2)
        counter.assertNone()

        # does not pass filter

        # TODO implement rest

        self.initializeContainer(container)
        counter.reset()
        item = container.addItemAfter(None, id3)
        counter.assertNone()
        item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id3)
        counter.assertNone()

        self.initializeContainer(container)
        counter.reset()
        item = container.addItemAfter(container.firstItemId(), id3)
        counter.assertNone()
        item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id3)
        counter.assertNone()

        self.initializeContainer(container)
        counter.reset()
        item = container.addItemAfter(container.lastItemId(), id3)
        counter.assertNone()
        item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id3)
        counter.assertNone()

        self.initializeContainer(container)
        counter.reset()
        item = container.addItemAt(0, id3)
        counter.assertNone()
        item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id3)
        counter.assertNone()

        self.initializeContainer(container)
        counter.reset()
        item = container.addItemAt(1, id3)
        counter.assertNone()
        item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id3)
        counter.assertNone()

        self.initializeContainer(container)
        counter.reset()
        item = container.addItemAt(len(container), id3)
        counter.assertNone()
        item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id3)
        counter.assertNone()

        # passes filter

        self.initializeContainer(container)
        counter.reset()
        item = container.addItem(id1)
        counter.assertNone()
        item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id1)
        counter.assertOnce()
        container.removeItem(id1)
        counter.assertOnce()
        # already removed
        container.removeItem(id1)
        counter.assertNone()

        item = container.addItem(id3)
        counter.assertNone()
        item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id3)
        counter.assertNone()
        # not visible
        container.removeItem(id3)
        counter.assertNone()

        # remove all

        self.initializeContainer(container)
        item = container.addItem(id1)
        item.getItemProperty(self.FULLY_QUALIFIED_NAME).setValue(id1)
        counter.reset()
        container.removeAllItems()
        counter.assertOnce()
        # no visible items
        container.removeAllItems()
        counter.assertNone()
开发者ID:kranthikumar,项目名称:muntjac,代码行数:104,代码来源:indexed_container_test.py


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