Exemplo n.º 1
0
def test_find_delimiter_pos_simple():
    """Simple tests to find the various delimiters"""
    assert properties._find_delimiter(u"key=value", [u"=", u":", u" "]) == ('=', 3)
    assert properties._find_delimiter(u"key:value", [u"=", u":", u" "]) == (':', 3)
    assert properties._find_delimiter(u"key value", [u"=", u":", u" "]) == (' ', 3)
    # NOTE this is valid in Java properties, the key is then the empty string
    assert properties._find_delimiter(u"= value", [u"=", u":", u" "]) == ('=', 0)
Exemplo n.º 2
0
def test_find_delimiter_pos_simple():
    """Simple tests to find the various delimiters"""
    assert properties._find_delimiter(u"key=value", [u"=", u":", u" "]) == ('=', 3)
    assert properties._find_delimiter(u"key:value", [u"=", u":", u" "]) == (':', 3)
    assert properties._find_delimiter(u"key value", [u"=", u":", u" "]) == (' ', 3)
    # NOTE this is valid in Java properties, the key is then the empty string
    assert properties._find_delimiter(u"= value", [u"=", u":", u" "]) == ('=', 0)
Exemplo n.º 3
0
def test_find_delimiter_pos_multiple():
    """Find delimiters when multiple potential delimietes are involved"""
    assert properties._find_delimiter(u"key=value:value",
                                      [u"=", u":", u" "]) == ('=', 3)
    assert properties._find_delimiter(u"key:value=value",
                                      [u"=", u":", u" "]) == (':', 3)
    assert properties._find_delimiter(u"key value=value",
                                      [u"=", u":", u" "]) == (' ', 3)
Exemplo n.º 4
0
def test_find_delimiter_pos_escapes():
    """Find delimiters when potential earlier delimiters are escaped"""
    assert properties._find_delimiter(u"key\:=value",
                                      [u"=", u":", u" "]) == ('=', 5)
    assert properties._find_delimiter(u"key\=: value",
                                      [u"=", u":", u" "]) == (':', 5)
    assert properties._find_delimiter(u"key\   value",
                                      [u"=", u":", u" "]) == (' ', 5)
    assert properties._find_delimiter(u"key\ key\ key\: = value",
                                      [u"=", u":", u" "]) == ('=', 16)
Exemplo n.º 5
0
def test_find_delimiter_pos_whitespace():
    """Find delimiters when whitespace is involved"""
    assert properties._find_delimiter(u"key = value", [u"=", u":", u" "]) == ('=', 4)
    assert properties._find_delimiter(u"key : value", [u"=", u":", u" "]) == (':', 4)
    assert properties._find_delimiter(u"key   value", [u"=", u":", u" "]) == (' ', 3)
    assert properties._find_delimiter(u"key value = value", [u"=", u":", u" "]) == (' ', 3)
    assert properties._find_delimiter(u"key value value", [u"=", u":", u" "]) == (' ', 3)
    assert properties._find_delimiter(u" key = value", [u"=", u":", u" "]) == ('=', 5)
Exemplo n.º 6
0
def test_find_delimiter_pos_whitespace():
    """Find delimiters when whitespace is involved"""
    assert properties._find_delimiter(u"key = value", [u"=", u":", u" "]) == ('=', 4)
    assert properties._find_delimiter(u"key : value", [u"=", u":", u" "]) == (':', 4)
    assert properties._find_delimiter(u"key   value", [u"=", u":", u" "]) == (' ', 3)
    assert properties._find_delimiter(u"key value = value", [u"=", u":", u" "]) == (' ', 3)
    assert properties._find_delimiter(u"key value value", [u"=", u":", u" "]) == (' ', 3)
    assert properties._find_delimiter(u" key = value", [u"=", u":", u" "]) == ('=', 5)
Exemplo n.º 7
0
    def test_fullspec_line_continuation(self):
        """Whitespace delimiter and pre whitespace in line continuation are dropped"""
        prop_source = ur"""fruits                           apple, banana, pear, \
                                  cantaloupe, watermelon, \
                                  kiwi, mango
"""
        prop_store = self.propparse(prop_source)
        print prop_store
        assert len(prop_store.units) == 1
        unit = prop_store.units[0]
        print unit
        assert properties._find_delimiter(prop_source, [u"=", u":", u" "]) == (' ', 6)
        assert unit.name == u"fruits"
        assert unit.source == u"apple, banana, pear, cantaloupe, watermelon, kiwi, mango"
Exemplo n.º 8
0
    def test_fullspec_line_continuation(self):
        """Whitespace delimiter and pre whitespace in line continuation are dropped"""
        prop_source = r"""fruits                           apple, banana, pear, \
                                  cantaloupe, watermelon, \
                                  kiwi, mango
"""
        prop_store = self.propparse(prop_source)
        print(prop_store)
        assert len(prop_store.units) == 1
        unit = prop_store.units[0]
        print(unit)
        assert properties._find_delimiter(prop_source, [u"=", u":", u" "]) == (' ', 6)
        assert unit.name == u"fruits"
        assert unit.source == u"apple, banana, pear, cantaloupe, watermelon, kiwi, mango"
Exemplo n.º 9
0
def test_find_delimiter_pos_escapes():
    """Find delimiters when potential earlier delimiters are escaped"""
    assert properties._find_delimiter(u"key\:=value", [u"=", u":", u" "]) == ('=', 5)
    assert properties._find_delimiter(u"key\=: value", [u"=", u":", u" "]) == (':', 5)
    assert properties._find_delimiter(u"key\   value", [u"=", u":", u" "]) == (' ', 5)
    assert properties._find_delimiter(u"key\ key\ key\: = value", [u"=", u":", u" "]) == ('=', 16)
Exemplo n.º 10
0
def test_find_delimiter_pos_none():
    """Find delimiters when there isn't one"""
    assert properties._find_delimiter(u"key", [u"=", u":", u" "]) == (None, -1)
    assert properties._find_delimiter(u"key\=\:\ ", [u"=", u":", u" "]) == (None, -1)
Exemplo n.º 11
0
def test_find_delimiter_pos_multiple():
    """Find delimiters when multiple potential delimiters are involved"""
    assert properties._find_delimiter(u"key=value:value", [u"=", u":", u" "]) == ('=', 3)
    assert properties._find_delimiter(u"key:value=value", [u"=", u":", u" "]) == (':', 3)
    assert properties._find_delimiter(u"key value=value", [u"=", u":", u" "]) == (' ', 3)
Exemplo n.º 12
0
def test_find_delimiter_pos_none():
    """Find delimiters when there isn't one"""
    assert properties._find_delimiter(u"key", [u"=", u":", u" "]) == (None, -1)
    assert properties._find_delimiter(u"key\=\:\ ",
                                      [u"=", u":", u" "]) == (None, -1)