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


Python RevisionMap._get_base_revisions方法代碼示例

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


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

示例1: LabeledBranchTest

# 需要導入模塊: from alembic.script.revision import RevisionMap [as 別名]
# 或者: from alembic.script.revision.RevisionMap import _get_base_revisions [as 別名]
class LabeledBranchTest(DownIterateTest):
    def test_dupe_branch_collection(self):
        fn = lambda: [
            Revision('a', ()),
            Revision('b', ('a',)),
            Revision('c', ('b',), branch_labels=['xy1']),
            Revision('d', ()),
            Revision('e', ('d',), branch_labels=['xy1']),
            Revision('f', ('e',))
        ]
        assert_raises_message(
            RevisionError,
            r"Branch name 'xy1' in revision (?:e|c) already "
            "used by revision (?:e|c)",
            getattr, RevisionMap(fn), "_revision_map"
        )

    def test_filter_for_lineage_labeled_head_across_merge(self):
        fn = lambda: [
            Revision('a', ()),
            Revision('b', ('a', )),
            Revision('c1', ('b', ), branch_labels='c1branch'),
            Revision('c2', ('b', )),
            Revision('d', ('c1', 'c2')),

        ]
        map_ = RevisionMap(fn)
        c1 = map_.get_revision('c1')
        c2 = map_.get_revision('c2')
        d = map_.get_revision('d')
        eq_(
            map_.filter_for_lineage([c1, c2, d], "[email protected]"),
            [c1, c2, d]
        )

    def test_filter_for_lineage_heads(self):
        eq_(
            self.map.filter_for_lineage(
                [self.map.get_revision("f")],
                "heads"
            ),
            [self.map.get_revision("f")]
        )

    def setUp(self):
        self.map = RevisionMap(lambda: [
            Revision('a', (), branch_labels='abranch'),
            Revision('b', ('a',)),
            Revision('somelongername', ('b',)),
            Revision('c', ('somelongername',)),
            Revision('d', ()),
            Revision('e', ('d',), branch_labels=['ebranch']),
            Revision('someothername', ('e',)),
            Revision('f', ('someothername',)),
        ])

    def test_get_base_revisions_labeled(self):
        eq_(
            self.map._get_base_revisions("[email protected]"),
            ['a']
        )

    def test_get_current_named_rev(self):
        eq_(
            self.map.get_revision("[email protected]"),
            self.map.get_revision("f")
        )

    def test_get_base_revisions(self):
        eq_(
            self.map._get_base_revisions("base"),
            ['a', 'd']
        )

    def test_iterate_head_to_named_base(self):
        self._assert_iteration(
            "heads", "[email protected]",
            ['f', 'someothername', 'e', 'd']
        )

        self._assert_iteration(
            "heads", "[email protected]",
            ['c', 'somelongername', 'b', 'a']
        )

    def test_iterate_named_head_to_base(self):
        self._assert_iteration(
            "[email protected]", "base",
            ['f', 'someothername', 'e', 'd']
        )

        self._assert_iteration(
            "[email protected]", "base",
            ['c', 'somelongername', 'b', 'a']
        )

    def test_iterate_named_head_to_heads(self):
        self._assert_iteration(
            "heads", "[email protected]",
            ['f'],
#.........這裏部分代碼省略.........
開發者ID:RazerM,項目名稱:alembic,代碼行數:103,代碼來源:test_revision.py


注:本文中的alembic.script.revision.RevisionMap._get_base_revisions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。