當前位置: 首頁>>代碼示例>>Python>>正文


Python Collector.file_for_path方法代碼示例

本文整理匯總了Python中collector.Collector.file_for_path方法的典型用法代碼示例。如果您正苦於以下問題:Python Collector.file_for_path方法的具體用法?Python Collector.file_for_path怎麽用?Python Collector.file_for_path使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在collector.Collector的用法示例。


在下文中一共展示了Collector.file_for_path方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_enhance_file_elements

# 需要導入模塊: from collector import Collector [as 別名]
# 或者: from collector.Collector import file_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.file_for_path方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。