Ejemplo n.º 1
0
    def setUp(self):
        Content = [
            # Right case
            'test no backslash',
            'test with backslash \\',
            'continue second line',

            # Do not precede with whitespace
            '\\',

            # Empty line after backlash is not allowed
            'line with backslash \\',
            ''
        ]
        self.dec = _DecBase(FileContent('dummy', Content))
Ejemplo n.º 2
0
 def setUp(self):
     self.dec = _DecBase(FileContent('dummy', []))
Ejemplo n.º 3
0
 def GetObj(self, Content):
     Obj = _DecLibraryclass(FileContent('dummy', Content.splitlines()))
     Obj._RawData.CurrentLine = Obj._RawData.GetNextLine()
     return Obj
Ejemplo n.º 4
0
 def GetObj(self, Content):
     Obj = _DecGuid(FileContent('dummy', Content.splitlines()))
     Obj._RawData.CurrentLine = Obj._RawData.GetNextLine()
     Obj._RawData.CurrentScope = [('guids'.upper(), 'COMMON')]
     return Obj
Ejemplo n.º 5
0
    def testParse(self):
        Content = \
        '''# Top comment
        [TOP]
          # sub1 head comment
          (test item has both head and tail comment) # sub1 tail comment
          # sub2 head comment
          (test item has head and special tail comment)
          # @comment test TailCommentStrategy branch

          (test item has no comment)

        # test NextLine branch
        [TOP]
          sub-item
        '''
        dec = TestTop(FileContent('dummy', Content.splitlines()))
        dec.Parse()

        # Two sections
        self.assertEqual(len(dec.ItemObject), 2)

        data = dec.ItemObject[0]
        self.assertEqual(data._HeadComment[0][0], '# Top comment')
        self.assertEqual(data._HeadComment[0][1], 1)

        # 3 subitems
        self.assertEqual(len(data.ItemList), 3)

        dataitem = data.ItemList[0]
        self.assertEqual(dataitem.String,
                         '(test item has both head and tail comment)')
        # Comment content
        self.assertEqual(dataitem._HeadComment[0][0], '# sub1 head comment')
        self.assertEqual(dataitem._TailComment[0][0], '# sub1 tail comment')
        # Comment line number
        self.assertEqual(dataitem._HeadComment[0][1], 3)
        self.assertEqual(dataitem._TailComment[0][1], 4)

        dataitem = data.ItemList[1]
        self.assertEqual(dataitem.String,
                         '(test item has head and special tail comment)')
        # Comment content
        self.assertEqual(dataitem._HeadComment[0][0], '# sub2 head comment')
        self.assertEqual(dataitem._TailComment[0][0],
                         '# @comment test TailCommentStrategy branch')
        # Comment line number
        self.assertEqual(dataitem._HeadComment[0][1], 5)
        self.assertEqual(dataitem._TailComment[0][1], 7)

        dataitem = data.ItemList[2]
        self.assertEqual(dataitem.String, '(test item has no comment)')
        # Comment content
        self.assertEqual(dataitem._HeadComment, [])
        self.assertEqual(dataitem._TailComment, [])

        data = dec.ItemObject[1]
        self.assertEqual(data._HeadComment[0][0], '# test NextLine branch')
        self.assertEqual(data._HeadComment[0][1], 11)

        # 1 subitems
        self.assertEqual(len(data.ItemList), 1)

        dataitem = data.ItemList[0]
        self.assertEqual(dataitem.String, 'sub-item')
        self.assertEqual(dataitem._HeadComment, [])
        self.assertEqual(dataitem._TailComment, [])