Ejemplo n.º 1
0
    def test_attribute_value_not_quoted_when_looks_like_key(self):
        sut = Element('')
        s1 = sut._parse_attribute_dictionary(
            '''{name:"viewport", content:"width:device-width, initial-scale:1, minimum-scale:1, maximum-scale:1"}'''
        )
        eq_(
            s1['content'],
            'width:device-width, initial-scale:1, minimum-scale:1, maximum-scale:1'
        )
        eq_(s1['name'], 'viewport')

        sut = Element('')
        s1 = sut._parse_attribute_dictionary(
            '''{style:"a:x, b:'y', c:1, e:3"}''')
        eq_(s1['style'], "a:x, b:'y', c:1, e:3")

        sut = Element('')
        s1 = sut._parse_attribute_dictionary(
            '''{style:"a:x, b:'y', c:1, d:\\"dk\\", e:3"}''')
        eq_(s1['style'], '''a:x, b:'y', c:1, d:"dk", e:3''')

        sut = Element('')
        s1 = sut._parse_attribute_dictionary(
            '''{style:'a:x, b:\\'y\\', c:1, d:"dk", e:3'}''')
        eq_(s1['style'], '''a:x, b:'y', c:1, d:"dk", e:3''')
Ejemplo n.º 2
0
        def test_dashes_work_in_attribute_quotes(self):
            sut = Element('')
            s1 = sut._parse_attribute_dictionary('''{"data-url":"something", "class":"blah"}''')
            eq_(s1['data-url'],'something')
            eq_(s1['class'], 'blah')

            s1 = sut._parse_attribute_dictionary('''{data-url:"something", class:"blah"}''')
            eq_(s1['data-url'],'something')
            eq_(s1['class'], 'blah')
Ejemplo n.º 3
0
    def test_dashes_work_in_attribute_quotes(self):
        sut = Element("")
        s1 = sut._parse_attribute_dictionary("""{"data-url":"something", "class":"blah"}""")
        eq_(s1["data-url"], "something")
        eq_(s1["class"], "blah")

        s1 = sut._parse_attribute_dictionary("""{data-url:"something", class:"blah"}""")
        eq_(s1["data-url"], "something")
        eq_(s1["class"], "blah")
Ejemplo n.º 4
0
    def test_dashes_work_in_attribute_quotes(self):
        sut = Element('')
        s1 = sut._parse_attribute_dictionary(
            '''{"data-url":"something", "class":"blah"}''')
        eq_(s1['data-url'], 'something')
        eq_(s1['class'], 'blah')

        s1 = sut._parse_attribute_dictionary(
            '''{data-url:"something", class:"blah"}''')
        eq_(s1['data-url'], 'something')
        eq_(s1['class'], 'blah')
Ejemplo n.º 5
0
        def test_attribute_value_not_quoted_when_looks_like_key(self):
            sut = Element('')
            s1 = sut._parse_attribute_dictionary('''{name:"viewport", content:"width:device-width, initial-scale:1, minimum-scale:1, maximum-scale:1"}''')
            eq_(s1['content'], 'width:device-width, initial-scale:1, minimum-scale:1, maximum-scale:1')
            eq_(s1['name'], 'viewport')

            sut = Element('')
            s1 = sut._parse_attribute_dictionary('''{style:"a:x, b:'y', c:1, e:3"}''')
            eq_(s1['style'], "a:x, b:'y', c:1, e:3")

            sut = Element('')
            s1 = sut._parse_attribute_dictionary('''{style:"a:x, b:'y', c:1, d:\\"dk\\", e:3"}''')
            eq_(s1['style'], '''a:x, b:'y', c:1, d:"dk", e:3''')

            sut = Element('')
            s1 = sut._parse_attribute_dictionary('''{style:'a:x, b:\\'y\\', c:1, d:"dk", e:3'}''')
            eq_(s1['style'], '''a:x, b:'y', c:1, d:"dk", e:3''')
Ejemplo n.º 6
0
        def test_attributes_parse(self):
            sut = Element('')

            s1 = sut._parse_attribute_dictionary('''{a:'something',"b":None,'c':2}''')
            eq_(s1['a'][0], 'something')
            eq_(s1['b'][0], None)
            eq_(s1['c'][0], 2)

            eq_(sut.attributes, "a='something' c='2' b")
Ejemplo n.º 7
0
        def test_attributes_parse(self):
            sut = Element('')

            s1 = sut._parse_attribute_dictionary('''{a:'something',"b":None,'c':2,d:"= some_var"}''')
            eq_(s1['a'],'something')
            eq_(s1['b'],None)
            eq_(s1['c'],2)
            eq_(s1['d'],'{{some_var}}')

            eq_(sut.attributes, "a='something' c='2' b d='{{some_var}}'")
Ejemplo n.º 8
0
    def test_attribute_value_not_quoted_when_looks_like_key(self):
        sut = Element("")
        s1 = sut._parse_attribute_dictionary(
            """{name:"viewport", content:"width:device-width, initial-scale:1, minimum-scale:1, maximum-scale:1"}"""
        )
        eq_(s1["content"], "width:device-width, initial-scale:1, minimum-scale:1, maximum-scale:1")
        eq_(s1["name"], "viewport")

        sut = Element("")
        s1 = sut._parse_attribute_dictionary("""{style:"a:x, b:'y', c:1, e:3"}""")
        eq_(s1["style"], "a:x, b:'y', c:1, e:3")

        sut = Element("")
        s1 = sut._parse_attribute_dictionary("""{style:"a:x, b:'y', c:1, d:\\"dk\\", e:3"}""")
        eq_(s1["style"], """a:x, b:'y', c:1, d:"dk", e:3""")

        sut = Element("")
        s1 = sut._parse_attribute_dictionary("""{style:'a:x, b:\\'y\\', c:1, d:"dk", e:3'}""")
        eq_(s1["style"], """a:x, b:'y', c:1, d:"dk", e:3""")
Ejemplo n.º 9
0
    def test_attributes_parse(self):
        sut = Element("")

        s1 = sut._parse_attribute_dictionary("""{a:'something',"b":None,'c':2,d:"= some_var"}""")
        eq_(s1["a"], "something")
        eq_(s1["b"], None)
        eq_(s1["c"], 2)
        eq_(s1["d"], "{{some_var}}")

        eq_(sut.attributes, "a='something' c='2' b d='{{some_var}}'")
Ejemplo n.º 10
0
        def test_attributes_parse(self):
            sut = Element('')

            s1 = sut._parse_attribute_dictionary('''{:a => 'something',"b": None, d: "asd", 'c':2}''')
            eq_(s1['a'], 'something')
            eq_(s1['b'], None)
            eq_(s1['d'], 'asd')
            eq_(s1['c'], 2)

            eq_(sut.attributes, "a='something' d='asd' c='2' b")
Ejemplo n.º 11
0
    def test_attributes_parse(self):
        sut = Element('')

        s1 = sut._parse_attribute_dictionary(
            '''{a:'something',"b":None,'c':2}''')
        eq_(s1['a'], 'something')
        eq_(s1['b'], None)
        eq_(s1['c'], 2)

        eq_(sut.attributes, "a='something' c='2' b")
Ejemplo n.º 12
0
    def test_attributes_parse(self):
        sut = Element('')

        s1 = sut._parse_attribute_dictionary(
            '''{a:'something',"b":None,'c':2,d:"= some_var"}''')
        eq_(s1['a'], 'something')
        eq_(s1['b'], None)
        eq_(s1['c'], 2)
        eq_(s1['d'], '{{some_var}}')

        eq_(sut.attributes, "a='something' c='2' b d='{{some_var}}'")
Ejemplo n.º 13
0
        def test_attributes_array(self):
            sut = Element('')
            s1 = sut._parse_attribute_dictionary('''{ar: (1, 'a',3), "list":[1, None, "bcd"]}''')

            eq_(sut.attributes, "ar='1 a 3' list='1 None bcd'")
Ejemplo n.º 14
0
        def test_attributes_order(self):
            sut = Element('')
            s1 = sut._parse_attribute_dictionary('''{'z':1, 'a':2, 'b':3}''')

            eq_(sut.attributes, "z='1' a='2' b='3'")