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('') == ''
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("") == ""
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']
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 '"
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 '"
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 '"
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("[да, нет]") == ["да", "нет"]
def backslash(): assert distinguish("\\_bar") == "_bar" assert distinguish("foo\\_") == "foo_" assert distinguish("foo\\\\bar") == "foo\\bar"
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('[да, нет]') == ["да", "нет"]
def backslash(): assert distinguish('\\_bar') == '_bar' assert distinguish('foo\\_') == 'foo_' assert distinguish('foo\\\\bar') == 'foo\\bar'