Esempio n. 1
0
def types():

    for val in ['None', 'none', '~', 'null']:
        assert distinguish(val) == None

    for val in ['3.14', '42.0', '-0.01']:
        assert distinguish(val) == float(val)

    for val in ['1', '2', '-1', '9000']:
        assert distinguish(val) == int(val)

    assert distinguish('test') == 'test'
    assert distinguish('') == ''
Esempio n. 2
0
def types():

    for val in ["None", "none", "~", "null"]:
        assert distinguish(val) == None

    for val in ["3.14", "42.0", "-0.01"]:
        assert distinguish(val) == float(val)

    for val in ["1", "2", "-1", "9000"]:
        assert distinguish(val) == int(val)

    assert distinguish("test") == "test"
    assert distinguish("") == ""
Esempio n. 3
0
def quotes():

    assert distinguish('"') == '"'
    assert distinguish('""') == ''

    assert distinguish('Foo"') == 'Foo"'
    assert distinguish('"Foo') == '"Foo'

    assert distinguish('"Foo" Bar') == '"Foo" Bar'
    assert distinguish('"Foo Bar"') == 'Foo Bar'

    assert distinguish("\"'bout \" and '\"") == "'bout \" and '"

    # quote commas, so they are not recognized as a new part
    assert distinguish('["X+ext(foo, bar=123)", other]') == ["X+ext(foo, bar=123)", "other"]
    assert distinguish('["a,b,c,d", a, b, c]') == ['a,b,c,d', 'a', 'b', 'c']
Esempio n. 4
0
def quotes():

    assert distinguish('"') == '"'
    assert distinguish('""') == ''

    assert distinguish('Foo"') == 'Foo"'
    assert distinguish('"Foo') == '"Foo'

    assert distinguish('"Foo" Bar') == '"Foo" Bar'
    assert distinguish('"Foo Bar"') == 'Foo Bar'

    assert distinguish("\"'bout \" and '\"") == "'bout \" and '"
Esempio n. 5
0
def testQuotes():

    assert distinguish('"') == '"'
    assert distinguish('""') == ''

    assert distinguish('Foo"') == 'Foo"'
    assert distinguish('"Foo') == '"Foo'

    assert distinguish('"Foo" Bar') == '"Foo" Bar'
    assert distinguish('"Foo Bar"') == 'Foo Bar'

    assert distinguish("\"'bout \" and '\"") == "'bout \" and '"
Esempio n. 6
0
def quotes():

    assert distinguish('"') == '"'
    assert distinguish('""') == ""

    assert distinguish('Foo"') == 'Foo"'
    assert distinguish('"Foo') == '"Foo'

    assert distinguish('"Foo" Bar') == '"Foo" Bar'
    assert distinguish('"Foo Bar"') == "Foo Bar"

    assert distinguish('"\'bout " and \'"') == "'bout \" and '"
Esempio n. 7
0
def quotes():

    assert distinguish('"') == '"'
    assert distinguish('""') == ""

    assert distinguish('Foo"') == 'Foo"'
    assert distinguish('"Foo') == '"Foo'

    assert distinguish('"Foo" Bar') == '"Foo" Bar'
    assert distinguish('"Foo Bar"') == "Foo Bar"

    assert distinguish('"\'bout " and \'"') == "'bout \" and '"

    # quote commas, so they are not recognized as a new part
    assert distinguish('["X+ext(foo, bar=123)", other]') == ["X+ext(foo, bar=123)", "other"]
    assert distinguish('["a,b,c,d", a, b, c]') == ["a,b,c,d", "a", "b", "c"]

    # shlex tokenizer should not split on "+" and " "
    assert distinguish("[X+Y]") == ["X+Y"]
    assert distinguish("[foo bar, baz]") == ["foo bar", "baz"]
    assert distinguish("[Foo, ]") == ["Foo"]

    # non-ascii
    assert distinguish('["Föhn", "Bär"]') == ["Föhn", "Bär"]
    assert distinguish("[Bla, Calléjon]") == ["Bla", "Calléjon"]
    assert distinguish("[да, нет]") == ["да", "нет"]
Esempio n. 8
0
def backslash():

    assert distinguish("\\_bar") == "_bar"
    assert distinguish("foo\\_") == "foo_"
    assert distinguish("foo\\\\bar") == "foo\\bar"
Esempio n. 9
0
def quotes():

    assert distinguish('"') == '"'
    assert distinguish('""') == ''

    assert distinguish('Foo"') == 'Foo"'
    assert distinguish('"Foo') == '"Foo'

    assert distinguish('"Foo" Bar') == '"Foo" Bar'
    assert distinguish('"Foo Bar"') == 'Foo Bar'

    assert distinguish("\"'bout \" and '\"") == "'bout \" and '"

    # quote commas, so they are not recognized as a new part
    assert distinguish('["X+ext(foo, bar=123)", other]') == ["X+ext(foo, bar=123)", "other"]
    assert distinguish('["a,b,c,d", a, b, c]') == ['a,b,c,d', 'a', 'b', 'c']

    # shlex tokenizer should not split on "+" and " "
    assert distinguish("[X+Y]") == ["X+Y"]
    assert distinguish("[foo bar, baz]") == ["foo bar", "baz"]
    assert distinguish("[Foo, ]") == ["Foo"]

    # non-ascii
    assert distinguish('["Föhn", "Bär"]') == ["Föhn", "Bär"]
    assert distinguish('[Bla, Calléjon]') == ["Bla", "Calléjon"]
    assert distinguish('[да, нет]') == ["да", "нет"]
Esempio n. 10
0
def backslash():

    assert distinguish('\\_bar') == '_bar'
    assert distinguish('foo\\_') == 'foo_'
    assert distinguish('foo\\\\bar') == 'foo\\bar'
Esempio n. 11
0
def backslash():

    assert distinguish('\\_bar') == '_bar'
    assert distinguish('foo\\_') == 'foo_'
    assert distinguish('foo\\\\bar') == 'foo\\bar'