示例#1
0
 def test_merge_into_section_not_same_reference(self):
     target = Section('The title\n' 'Styleguide a.b')
     target.parse()
     source = Section('Title suffix\n' 'StyleguideExtendBefore a.c')
     source.parse()
     with self.assertRaises(InvalidMergeNotSameReferenceError):
         source.merge_into_section(target_section=target)
示例#2
0
 def test_merge_into_section_invalid_section_type(self):
     target = Section('The title\nStyleguide a.b')
     target.parse()
     source = Section('Title suffix\nStyleguide a.b')
     source.parse()
     with self.assertRaises(InvalidMergeSectionTypeError):
         source.merge_into_section(target_section=target)
示例#3
0
 def test_merge_into_section_before_no_title(self):
     target = Section('The title\nThe description\nStyleguide a.b')
     target.parse()
     source = Section('Extra description\nStyleguideExtendBefore a.b')
     source.parse()
     source.merge_into_section(target_section=target)
     self.assertEqual(target.title, 'The title')
     self.assertEqual(target.description,
                      'Extra description\n\nThe description')
示例#4
0
 def test_merge_into_section_before_example(self):
     target = Section('The title\n'
                      'Example:\n  <em>example</em>\n'
                      'Styleguide a.b')
     target.parse()
     source = Section('Example:\n  <em>example2</em>\n'
                      'StyleguideExtendBefore a.b')
     source.parse()
     source.merge_into_section(target_section=target)
     self.assertEqual(target.examples[0].text, '<em>example2</em>')
     self.assertEqual(target.examples[1].text, '<em>example</em>')
示例#5
0
 def test_merge_into_section_before_sanity(self):
     target = Section('The title\n' 'The description\n' 'Styleguide a.b')
     target.parse()
     source = Section('Title: Title prefix\n'
                      'Extra description\n'
                      'StyleguideExtendBefore a.b')
     source.parse()
     source.merge_into_section(target_section=target)
     self.assertEqual(target.reference, 'a.b')
     self.assertEqual(target.title, 'Title prefix The title')
     self.assertEqual(target.description,
                      'Extra description\n\nThe description')
示例#6
0
 def test_merge_into_section_after_multiple_examples(self):
     target = Section(
         'The title\nExample:\n  <em>example</em>\nStyleguide a.b')
     target.parse()
     source = Section('Example:\n  <em>example2</em>\n'
                      'Example:\n  <em>example3</em>\n'
                      'StyleguideExtendAfter a.b')
     source.parse()
     source.merge_into_section(target_section=target)
     self.assertEqual(target.examples[0].text, '<em>example</em>')
     self.assertEqual(target.examples[1].text, '<em>example2</em>')
     self.assertEqual(target.examples[2].text, '<em>example3</em>')
示例#7
0
 def test_merge_into_section_after_sanity(self):
     target = Section('The title\n' 'The description\n' 'Styleguide a.b')
     target.parse()
     source = Section('Title: Title suffix\n'
                      'Extra description\n'
                      'StyleguideExtendAfter a.b')
     source.parse()
     source.merge_into_section(target_section=target)
     self.assertEqual(target.reference, 'a.b')
     self.assertEqual(target.title, 'The title Title suffix')
     self.assertEqual(target.description,
                      'The description\n\nExtra description')