def test_string(self): self.assertTrue(STRING.load(""" "algo" """).value == "algo") self.assertTrue( STRING.load(""" "algo y algo" """).value == "algo y algo") self.assertTrue( STRING.load(""" "algo es \\"algo\\"" """).value == '''algo es \\"algo\\"''') self.assertTrue( STRING.load(""" "algo es \\"algo\\"" """).unescape() == '''algo es "algo"''')
syntax = delimitedList(Expression.names('expressions'), delim=","), ) ExpressionList.ebnf( syntax = delimitedList(Expression.names('expressions'), delim=","), ) ArraySubscripts.ebnf( syntax = Suppress("[") + delimitedList(Subscript.names('subscripts'), delim=",") + Suppress("]"), ) Subscript.ebnf( syntax = Suppress(":") ^ Expression.name("expression"), ) ComponentReference.ebnf( syntax = IDENT.name("identifier"), ) Comment.ebnf( syntax = StringComment.name("comment") + Optional(Annotation.name("annotation")), ) StringComment.ebnf( syntax = delimitedList(STRING.names('comments'), delim="+"), ) Annotation.ebnf( syntax = Literal("annotation") + ClassModification.name('modification'), )
Expression.ebnf(syntax=IDENT.name("identifier")) NamedArguments.ebnf(syntax=delimitedList(NamedArgument.names('arguments'), delim=","), ) NamedArgument.ebnf(syntax=IDENT.name('identifier') + Suppress("=") + Expression.name('expression'), ) OutputExpressionList.ebnf(syntax=delimitedList(Expression.names('expressions'), delim=","), ) ExpressionList.ebnf(syntax=delimitedList(Expression.names('expressions'), delim=","), ) ArraySubscripts.ebnf(syntax=Suppress("[") + delimitedList(Subscript.names('subscripts'), delim=",") + Suppress("]"), ) Subscript.ebnf(syntax=Suppress(":") ^ Expression.name("expression"), ) ComponentReference.ebnf(syntax=IDENT.name("identifier"), ) Comment.ebnf(syntax=StringComment.name("comment") + Optional(Annotation.name("annotation")), ) StringComment.ebnf(syntax=delimitedList(STRING.names('comments'), delim="+"), ) Annotation.ebnf(syntax=Literal("annotation") + ClassModification.name('modification'), )
def test_string(self): self.assertTrue(STRING.load(""" "algo" """).value == "algo") self.assertTrue(STRING.load(""" "algo y algo" """).value == "algo y algo") self.assertTrue(STRING.load(""" "algo es \\"algo\\"" """).value == '''algo es \\"algo\\"''') self.assertTrue(STRING.load(""" "algo es \\"algo\\"" """).unescape() == '''algo es "algo"''')
def test_string(self): self.assertEqual(STRING("algo y algo").dump(), '''"algo y algo"''')