<s> from __future__ import unicode_literals <EOL> import pytest <EOL> from arpeggio import ParserPython , ZeroOrMore , OneOrMore , NonTerminal , Terminal , NoMatch , Combine <EOL> from arpeggio . peg import ParserPEG <EOL> def test_combine_python ( ) : <EOL> def root ( ) : return my_rule ( ) , "<STR_LIT:.>" <EOL> def my_rule ( ) : return Combine ( ZeroOrMore ( "<STR_LIT:a>" ) , OneOrMore ( "<STR_LIT:b>" ) ) <EOL> parser = ParserPython ( root ) <EOL> input1 = "<STR_LIT>" <EOL> input2 = "<STR_LIT>" <EOL> ptree1 = parser . parse ( input1 ) <EOL> with pytest . raises ( NoMatch ) : <EOL> ptree2 = parser . parse ( input2 ) <EOL> assert isinstance ( ptree1 , NonTerminal ) <EOL> assert isinstance ( ptree1 [ <NUM_LIT:0> ] , Terminal ) <EOL> assert ptree1 [ <NUM_LIT:0> ] . value == "<STR_LIT>" </s>
