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


Python Book.last_child_leaf方法代码示例

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


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

示例1: TestBook

# 需要导入模块: from books.models import Book [as 别名]
# 或者: from books.models.Book import last_child_leaf [as 别名]

#.........这里部分代码省略.........
        self.failUnless(s3b.hidden)
        self.failUnlessEqual(s3b.astext(), "")

    def test_walk(self):

        from repoze.bfg.traversal import model_path
        from cStringIO import StringIO

        out = StringIO()
        for section in self.book.walk():
            print >> out, model_path(section)
            # print >>out, section.astext()
        target = """0000
0000/1
0000/2
0000/2/1
0000/2/2
0000/3
0000/3/1
0000/3/1/1
0000/3/2
"""
        self.failUnlessEqual(out.getvalue(), target)

    def test_next(self):

        from repoze.bfg.traversal import model_path
        from cStringIO import StringIO

        out = StringIO()

        next = self.book.first_child_leaf()
        while next:
            print >> out, model_path(next)
            next = next.next_leaf()
        target = """0000/1
0000/2/1
0000/2/2
0000/3/1/1
0000/3/2
"""
        self.failUnlessEqual(out.getvalue(), target)

    def test_prev(self):

        from repoze.bfg.traversal import model_path
        from cStringIO import StringIO

        out = StringIO()

        prev = self.book.last_child_leaf()
        while prev:
            print >> out, model_path(prev)
            prev = prev.previous_leaf()
        target = """0000/3/2
0000/3/1/1
0000/2/2
0000/2/1
0000/1
"""
        self.failUnlessEqual(out.getvalue(), target)

    def test_html(self):
        target = u"""<div class="genre_talk section" id="section-1">
<h1>Section 1</h1>
<p>first
ěščřžýáíúů</p>
</div>
<div class="section" id="section-2">
<h1>Section 2</h1>
<div class="section" id="section-2-a">
<h2>Section 2.a</h2>
<p>second alpha</p>
</div>
<div class="section" id="section-2-b">
<h2>Section 2.b</h2>
<p>second beta</p>
</div>
</div>
<div class="section" id="section-3">
<h1>Section 3</h1>
<div class="section" id="section-3-a">
<h2>Section 3.a</h2>
<p>third alpha</p>
<div class="section" id="section-3-a-1">
<h3>Section 3.a.1</h3>
<p>third alpha.1</p>
</div>
</div>
<div class="hidden section" id="section-3-b">
<h2>Section 3.b</h2>
</div>
</div>
"""
        output = self.book.ashtml()
        # self.failUnlessEqual(len(target), len(output))
        self.failUnlessEqual(output, target, output)

        output = self.book.ashtml()
        self.failUnlessEqual(output, target, output)
开发者ID:vilos,项目名称:rstlibrary,代码行数:104,代码来源:test_book.py


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