示例#1
0
    def test_parse_inherits(self):
        tree = IndentationTree.parse([
            'base',
            'derive with same name',
            ':: abstract base',
            'derived :: base',
            '  child base :: base',
            '  other child :: child base',
            '  derive with same name ::',
            'other derived :: abstract base',
        ])

        prop = PropertyBagParser.parse(tree)

        self.assert_prop(prop, '', '', '', [
            PropAsserter('base', ''),
            PropAsserter('derive with same name', ''),
            PropAsserter('derived', '', 'base', [
                PropAsserter('child base', '', 'base'),
                PropAsserter('other child', '', 'child base'),
                PropAsserter('derive with same name', '',
                             'derive with same name')
            ]),
            PropAsserter('other derived', '', 'abstract base')
        ])
示例#2
0
    def test_parse_simple(self):
        tree = IndentationTree.parse(["simple name = simple value"])

        prop = PropertyBagParser.parse(tree)

        self.assert_prop(prop, '', '', '',
                         [PropAsserter('simple name', 'simple value')])
示例#3
0
    def test_parse_trimmed_whitespace(self):
        tree = IndentationTree.parse([
            "whitespace after    =    and before  ",
        ])

        prop = PropertyBagParser.parse(tree)

        self.assert_prop(prop, '', '', '',
                         [PropAsserter('whitespace after', 'and before')])
示例#4
0
    def test_parse_odd_characters(self):
        tree = IndentationTree.parse(
            ['!@#$%^&*-_+[]\\|{};:\'",<.>/? = !@#$%^&*-=_+[]\\|{};:\'",<.>/?'])

        prop = PropertyBagParser.parse(tree)

        self.assert_prop(prop, '', '', '', [
            PropAsserter('!@#$%^&*-_+[]\\|{};:\'",<.>/?',
                         '!@#$%^&*-=_+[]\\|{};:\'",<.>/?')
        ])
示例#5
0
    def test_parse_multiple_inheritence(self):
        tree = IndentationTree.parse([
            ':: a', '  foo = from a', '  bar = from a', ':: b',
            '  foo = from b', '  baz = from b', 'c :: a :: b',
            '  sprang = from c'
        ])

        prop = PropertyBagParser.parse(tree)

        self.assert_prop(prop, '', '', '', [
            PropAsserter('c', '', 'a,b', [
                PropAsserter('foo', 'from b'),
                PropAsserter('bar', 'from a'),
                PropAsserter('baz', 'from b'),
                PropAsserter('sprang', 'from c'),
            ])
        ])
示例#6
0
    def test_parse_multiline(self):
        tree = IndentationTree.parse([
            'multi-line =',
            '  first',
            '  second',
            '  third',
            'nest',
            '   multi-line =',
            '       first',
            '       second',
            '       third',
        ])

        prop = PropertyBagParser.parse(tree)

        self.assert_prop(prop, '', '', '', [
            PropAsserter('multi-line', 'first second third'),
            PropAsserter('nest', '', '',
                         [PropAsserter('multi-line', 'first second third')])
        ])
示例#7
0
    def test_parse_nested(self):
        tree = IndentationTree.parse([
            "parent",
            "  child1 = 1",
            "  child2",
            "    grandchild1 = blah",
            "    grandchild2 = blah",
            "  child3",
        ])

        prop = PropertyBagParser.parse(tree)

        self.assert_prop(prop, '', '', '', [
            PropAsserter('parent', '', '', [
                PropAsserter('child1', '1'),
                PropAsserter('child2', '', '', [
                    PropAsserter('grandchild1', 'blah'),
                    PropAsserter('grandchild2', 'blah'),
                ]),
                PropAsserter('child3', '')
            ])
        ])
示例#8
0
    def test_parse_inherit_with_same_name_does_not_reuse_self(self):
        tree = IndentationTree.parse([
            'foo',
            '  bar = in base',
            'a',
            '  foo ::',
            '    bar = overridden',
            'b',
            '  foo ::',
        ])

        prop = PropertyBagParser.parse(tree)

        self.assert_prop(prop, '', '', '', [
            PropAsserter('foo', '', '', [PropAsserter('bar', 'in base')]),
            PropAsserter('a', '', '', [
                PropAsserter('foo', '', '',
                             [PropAsserter('bar', 'overridden')])
            ]),
            PropAsserter('b', '', '', [
                PropAsserter('foo', '', '', [PropAsserter('bar', 'in base')])
            ]),
        ])