本文整理汇总了Python中botocore.docs.bcdoc.restdoc.DocumentStructure.clear_text方法的典型用法代码示例。如果您正苦于以下问题:Python DocumentStructure.clear_text方法的具体用法?Python DocumentStructure.clear_text怎么用?Python DocumentStructure.clear_text使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类botocore.docs.bcdoc.restdoc.DocumentStructure
的用法示例。
在下文中一共展示了DocumentStructure.clear_text方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestDocumentStructure
# 需要导入模块: from botocore.docs.bcdoc.restdoc import DocumentStructure [as 别名]
# 或者: from botocore.docs.bcdoc.restdoc.DocumentStructure import clear_text [as 别名]
class TestDocumentStructure(unittest.TestCase):
def setUp(self):
self.name = 'mydoc'
self.doc_structure = DocumentStructure(self.name)
def test_name(self):
self.assertEqual(self.doc_structure.name, self.name)
def test_path(self):
self.assertEqual(self.doc_structure.path, [self.name])
self.doc_structure.path = ['foo']
self.assertEqual(self.doc_structure.path, ['foo'])
def test_add_new_section(self):
section = self.doc_structure.add_new_section('mysection')
# Ensure the name of the section is correct
self.assertEqual(section.name, 'mysection')
# Ensure we can get the section.
self.assertEqual(
self.doc_structure.get_section('mysection'), section)
# Ensure the path is correct
self.assertEqual(section.path, ['mydoc', 'mysection'])
# Ensure some of the necessary attributes are passed to the
# the section.
self.assertEqual(section.style.indentation,
self.doc_structure.style.indentation)
self.assertEqual(section.translation_map,
self.doc_structure.translation_map)
self.assertEqual(section.hrefs,
self.doc_structure.hrefs)
def test_delete_section(self):
section = self.doc_structure.add_new_section('mysection')
self.assertEqual(
self.doc_structure.get_section('mysection'), section)
self.doc_structure.delete_section('mysection')
with self.assertRaises(KeyError):
section.get_section('mysection')
def test_create_sections_at_instantiation(self):
sections = ['intro', 'middle', 'end']
self.doc_structure = DocumentStructure(
self.name, section_names=sections)
# Ensure the sections are attached to the new document structure.
for section_name in sections:
section = self.doc_structure.get_section(section_name)
self.assertEqual(section.name, section_name)
def test_flush_structure(self):
section = self.doc_structure.add_new_section('mysection')
subsection = section.add_new_section('mysubsection')
self.doc_structure.writeln('1')
section.writeln('2')
subsection.writeln('3')
second_section = self.doc_structure.add_new_section('mysection2')
second_section.writeln('4')
contents = self.doc_structure.flush_structure()
# Ensure the contents were flushed out correctly
self.assertEqual(contents, six.b('1\n2\n3\n4\n'))
def test_flush_structure_hrefs(self):
section = self.doc_structure.add_new_section('mysection')
section.writeln('section contents')
self.doc_structure.hrefs['foo'] = 'www.foo.com'
section.hrefs['bar'] = 'www.bar.com'
contents = self.doc_structure.flush_structure()
self.assertIn(six.b('.. _foo: www.foo.com'), contents)
self.assertIn(six.b('.. _bar: www.bar.com'), contents)
def test_available_sections(self):
self.doc_structure.add_new_section('mysection')
self.doc_structure.add_new_section('mysection2')
self.assertEqual(
self.doc_structure.available_sections,
['mysection', 'mysection2']
)
def test_context(self):
context = {'Foo': 'Bar'}
section = self.doc_structure.add_new_section(
'mysection', context=context)
self.assertEqual(section.context, context)
# Make sure if context is not specified it is empty.
section = self.doc_structure.add_new_section('mysection2')
self.assertEqual(section.context, {})
def test_remove_all_sections(self):
self.doc_structure.add_new_section('mysection2')
self.doc_structure.remove_all_sections()
self.assertEqual(self.doc_structure.available_sections, [])
def test_clear_text(self):
self.doc_structure.write('Foo')
self.doc_structure.clear_text()
#.........这里部分代码省略.........