示例#1
0
    def test_with_two_bof_eof_warnings(self):
        reader = FileConfigParser(opener=self.opener)
        reader.include('test.conf')

        out = [i for i in reader]
        self.assertEqual([i.name for i in out],
                         ['context1', 'context2', 'context3'])

        variables = [i for i in out[0]]
        self.assertEqual(
            [(i.where.filename, i.where.lineno, i.variable, i.value)
             for i in variables],
            [('test.conf', 4, 'variable', 'value')])
        variables = [i for i in out[1]]
        self.assertEqual(
            [(i.where.filename, i.where.lineno, i.variable, i.value)
             for i in variables],
            [('test2.conf', 4, 'variable2', 'value2')])
        variables = [i for i in out[2]]
        self.assertEqual(
            [(i.where.filename, i.where.lineno, i.variable, i.value)
             for i in variables],
            [('test.conf', 8, 'variable3', 'value3')])

        self.assertLinted({'W_WSV_BOF': 2, 'W_WSV_EOF': 2})
示例#2
0
    def test_correct_linenumber(self):
        reader = FileConfigParser(opener=self.opener)
        reader.include('test.conf')

        out = [i for i in reader]
        self.assertEqual([i.name for i in out], ['context1'])

        variables = [i for i in out[0]]
        self.assertEqual(
            [(i.where.filename, i.where.lineno, i.variable, i.value)
             for i in variables],
            [('test2.conf', 1, 'variable2', 'value2'),
             ('test.conf', 3, 'variable', 'value')])
示例#3
0
    def test_with_leading_blanks(self):
        reader = FileConfigParser(opener=self.opener)
        reader.include('test.conf')

        out = [i for i in reader]
        self.assertEqual([i.name for i in out], ['context1'])

        variables = [i for i in out[0]]
        self.assertEqual(
            [(i.where.filename, i.where.lineno, i.variable, i.value)
             for i in variables],
            [('test.conf', 2, 'variable', 'value'),
             ('test2.conf', 1, 'variable3', 'value3'),
             ('test2.conf', 3, 'variable4', 'value4'),
             ('test.conf', 4, 'variable2', 'value2')])

        self.assertLinted({'W_FILE_CTRL_CHAR': 1, 'W_WSH_BOL': 5,
                           'W_WSH_CTRL': 1, 'W_WSH_VARSET': 2})
示例#4
0
    def test_normal(self):
        reader = FileConfigParser(opener=self.opener)
        reader.include('test.conf')

        out = [i for i in reader]
        self.assertEqual([i.name for i in out], ['context1', 'context2'])

        variables = [i for i in out[0]]
        self.assertEqual(
            [(i.where.filename, i.where.lineno, i.variable, i.value)
             for i in variables],
            [('test.conf', 2, 'variable', 'value'),
             ('test3.conf', 1, 'variable5', 'value5')])

        variables = [i for i in out[1]]
        self.assertEqual(
            [(i.where.filename, i.where.lineno, i.variable, i.value)
             for i in variables],
            [('test3.conf', 4, 'variable6', 'value6'),
             ('test2.conf', 2, 'variable3', 'value3'),
             ('test2.conf', 3, 'variable4', 'value4'),
             ('test.conf', 4, 'variable2', 'value2')])
示例#5
0
 def test_that_this_yields_an_eof_lint_message(self):
     reader = FileConfigParser(opener=self.opener_with_extra_space)
     reader.include('test.conf')
     out = [i for i in reader]
     del out
     self.assertLinted({'W_WSV_EOF': 1})
示例#6
0
 def test_that_this_yields_no_lint_messages(self):
     reader = FileConfigParser(opener=self.opener)
     reader.include('test.conf')
     out = [i for i in reader]
     del out
     self.assertLinted({})  # *not* W_WSV_EOF