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


Python Collector.folder_for_path方法代码示例

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


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

示例1: test_enhance_file_elements

# 需要导入模块: from collector import Collector [as 别名]
# 或者: from collector.Collector import folder_for_path [as 别名]
    def test_enhance_file_elements(self):
        c = Collector()
        aa_c = c.file_for_path("a/a/aa.c")
        ab_c = c.file_for_path("a/b/ab.c")
        b_c = c.file_for_path("b/b.c")
        baa_c = c.file_for_path("b/a/a/baa.c")

        a = c.folder_for_path("a")
        aa = c.folder_for_path("a/a")
        ab = c.folder_for_path("a/b")
        b = c.folder_for_path("b")
        ba = c.folder_for_path("b/a")
        baa = c.folder_for_path("b/a/a")

        self.assertEqual("a", a[collector.NAME])
        self.assertEqual("a", aa[collector.NAME])
        self.assertEqual("aa.c", aa_c[collector.NAME])
        self.assertEqual("b", ab[collector.NAME])
        self.assertEqual("ab.c", ab_c[collector.NAME])
        self.assertEqual("b", b[collector.NAME])
        self.assertEqual("b.c", b_c[collector.NAME])
        self.assertEqual("a", ba[collector.NAME])
        self.assertEqual("a", baa[collector.NAME])
        self.assertEqual("baa.c", baa_c[collector.NAME])

        c.enhance_file_elements()

        crf = list(c.collapsed_root_folders())
        self.assertItemsEqual([aa, ab, b], crf)

        self.assertEqual(a, aa[collector.ROOT])
        self.assertEqual(a, ab[collector.ROOT])
        self.assertEqual(b, ba[collector.ROOT])
        self.assertEqual(b, baa[collector.ROOT])

        self.assertItemsEqual([aa, ab], a[collector.SUB_FOLDERS])
        self.assertItemsEqual([], aa[collector.SUB_FOLDERS])
        self.assertItemsEqual([], ab[collector.SUB_FOLDERS])
        self.assertItemsEqual([ba], b[collector.SUB_FOLDERS])
        self.assertItemsEqual([baa], ba[collector.SUB_FOLDERS])
        self.assertItemsEqual([], baa[collector.SUB_FOLDERS])

        self.assertItemsEqual([], a[collector.FILES])
        self.assertItemsEqual([aa_c], aa[collector.FILES])
        self.assertItemsEqual([ab_c], ab[collector.FILES])
        self.assertItemsEqual([b_c], b[collector.FILES])
        self.assertItemsEqual([], ba[collector.FILES])
        self.assertItemsEqual([baa_c], baa[collector.FILES])

        self.assertEqual("a", a[collector.COLLAPSED_NAME])
        self.assertEqual("a/a", aa[collector.COLLAPSED_NAME])
        self.assertEqual("a/b", ab[collector.COLLAPSED_NAME])
        self.assertEqual("b", b[collector.COLLAPSED_NAME])
        self.assertEqual("a", ba[collector.COLLAPSED_NAME])
        self.assertEqual("a/a", baa[collector.COLLAPSED_NAME])

        self.assertItemsEqual([aa, ab], a[collector.COLLAPSED_SUB_FOLDERS])
        self.assertItemsEqual([], aa[collector.COLLAPSED_SUB_FOLDERS])
        self.assertItemsEqual([], ab[collector.COLLAPSED_SUB_FOLDERS])
        self.assertItemsEqual([baa], b[collector.COLLAPSED_SUB_FOLDERS])
        self.assertItemsEqual([baa], ba[collector.COLLAPSED_SUB_FOLDERS])
        self.assertItemsEqual([], baa[collector.COLLAPSED_SUB_FOLDERS])
开发者ID:kevincon,项目名称:puncover,代码行数:64,代码来源:collector_tests.py


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