Пример #1
0
 def test_parse_title_supplied(self):
     comment = 'The description\nStyleguide a.b'
     section = Section(comment)
     section.parse(title='Provided title')
     self.assertEqual(section.reference, 'a.b')
     self.assertEqual(section.title, 'Provided title')
     self.assertEqual(section.description, 'The description')
Пример #2
0
 def test_parse_type_extend_after_title_empty(self):
     comment = 'Title: \nStyleguideExtendAfter a.b'
     section = Section(comment)
     section.parse()
     self.assertEqual(section.reference, 'a.b')
     self.assertEqual(section.title, None)
     self.assertEqual(section.description, 'Title:')
Пример #3
0
 def test_parse_title_and_reference_supplied_with_body(self):
     comment = 'The description'
     section = Section(comment)
     section.parse(title='Provided title', reference='a.b')
     self.assertEqual(section.reference, 'a.b')
     self.assertEqual(section.title, 'Provided title')
     self.assertEqual(section.description, 'The description')
Пример #4
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)
Пример #5
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)
Пример #6
0
 def test_parse_type_replace_title_and_description(self):
     comment = 'The title\nThe description\nStyleguideReplace a.b'
     section = Section(comment)
     section.parse()
     self.assertEqual(section.reference, 'a.b')
     self.assertEqual(section.title, 'The title')
     self.assertEqual(section.description, 'The description')
Пример #7
0
 def test_parse_reference_supplied(self):
     comment = 'The title\nThe description'
     section = Section(comment)
     section.parse(reference='a.b')
     self.assertEqual(section.reference, 'a.b')
     self.assertEqual(section.title, 'The title')
     self.assertEqual(section.description, 'The description')
Пример #8
0
 def test_parse_type_extend_before_title_and_description(self):
     comment = 'Title: The title\nThe description\nStyleguideExtendBefore a.b'
     section = Section(comment)
     section.parse()
     self.assertEqual(section.reference, 'a.b')
     self.assertEqual(section.title, 'The title')
     self.assertEqual(section.description, 'The description')
Пример #9
0
 def parse_commentblock(self, commentblock, filepath):
     section = Section(commentblock, filepath=filepath)
     try:
         section.parse()
     except NotSectionError:
         pass
     else:
         self._add_section(section)
Пример #10
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')
Пример #11
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>')
Пример #12
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')
Пример #13
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>')
Пример #14
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')
Пример #15
0
    def setUp(self):
        comment = """
Form Button

Your standard form button.

    This is also part of the description!.

Example:
    <strong>Hello</strong>

Styleguide 2.1.1
        """
        self.section = Section(comment.strip(), 'example.css')
Пример #16
0
 def __make_section(self,
                    title='The title',
                    description=None,
                    modifiers=None,
                    markup=None,
                    reference='1.1'):
     commentparts = [title]
     for part in description, modifiers, markup:
         if part:
             commentparts.append(part)
     if reference:
         commentparts.append('Styleguide {}'.format(reference))
     comment = '\n\n'.join(commentparts)
     return Section(comment, filepath='example.css')
Пример #17
0
 def test_handles_when_no_reference(self):
     section = Section('Styleguide', 'example.css')
     with self.assertRaises(NotSectionError):
         section.parse()
Пример #18
0
 def test_parse_type_replace_title_empty(self):
     comment = 'StyleguideReplace a.b'
     section = Section(comment)
     with self.assertRaises(NotSectionError):
         section.parse()