def test_variable_varname():
 g = compile(u'((?P<varname>hello|world)|test)')
 m = g.match(u'hello')
 variables = m.variables()
 assert isinstance(variables, Variables)
 assert (variables.get(u'varname') == u'hello')
 assert (variables[u'varname'] == u'hello')
 m = g.match(u'world')
 variables = m.variables()
 assert isinstance(variables, Variables)
 assert (variables.get(u'varname') == u'world')
 assert (variables[u'varname'] == u'world')
 m = g.match(u'test')
 variables = m.variables()
 assert isinstance(variables, Variables)
 assert (variables.get(u'varname') is None)
 assert (variables[u'varname'] is None)

def test_variable_varname ( ) : g = compile ( u'((?P<varname>hello|world)|test)' ) m = g . match ( u'hello' ) variables = m . variables ( ) assert isinstance ( variables , Variables ) assert ( variables . get ( u'varname' ) == u'hello' ) assert ( variables [ u'varname' ] == u'hello' ) m = g . match ( u'world' ) variables = m . variables ( ) assert isinstance ( variables , Variables ) assert ( variables . get ( u'varname' ) == u'world' ) assert ( variables [ u'varname' ] == u'world' ) m = g . match ( u'test' ) variables = m . variables ( ) assert isinstance ( variables , Variables ) assert ( variables . get ( u'varname' ) is None ) assert ( variables [ u'varname' ] is None )
test variable with varname .