Ejemplo n.º 1
0
def test_Copy():
    env = actions.Environment()
    env.match = ['xyz']
    actions.Copy(0, 'D').interpret(env)
    assert env.attributes
    assert 'D' in env.attributes
    assert env.attributes['D'] == 'xyz'
Ejemplo n.º 2
0
 def __init__(self):
     env = actions.Environment()
     t = actions.Table("T")
     t.interpret(env)
     self._lookup = env._lookup
     e = actions.Entry(re.compile('abc'), 'XYZ')
     e.interpret(env)
Ejemplo n.º 3
0
def test_table():
    env = actions.Environment()
    t = actions.Table("T")
    assert not env._lookup
    assert not 'T' in env.tables
    t.interpret(env)
    assert env._lookup
    assert 'T' in env.tables
    assert env._lookup is env.tables['T']
Ejemplo n.º 4
0
def reparse():
	parser = argparse.ArgumentParser()
	parser.add_argument( "--script", "-s", metavar="FILE", help="Input script file", type=argparse.FileType( 'r' ), required=True )
	parser.add_argument( "--input", "-i", help="Input file to process (or - for stdin), defaults to stdin", default=sys.stdin, type=argparse.FileType( 'r' ) )
	parser.add_argument( "--output", "-o", help="Output file to generate (or - for stdout), defaults to stdout", default=sys.stdout, type=argparse.FileType( 'r' ) )
	parser.add_argument( "--showprogram", help="Print program to output for debug", action="store_true" )
	args = parser.parse_args()
	program = parse.scriptParser( args.script ).readStatements()
	if args.showprogram:
		program.show()
	env = actions.Environment()
	env.input = args.input
	env.output = args.output
	program.interpret( env )
	actions.PrintFooter().interpret( env )
Ejemplo n.º 5
0
	def test_done_fail( self ):
		text = 'Done\n'
		program = parse.scriptParser( io.StringIO( text ) ).readStatements()
		env = actions.Environment()
		env.input = io.StringIO( 'Not EOF' )
		self.assertRaises( Exception, program.interpret, env )
Ejemplo n.º 6
0
	def test_done_ok( self ):
		text = 'Done\n'
		program = parse.scriptParser( io.StringIO( text ) ).readStatements()
		env = actions.Environment()
		env.input = io.StringIO( '' )
		program.interpret( env )
Ejemplo n.º 7
0
def test_UseTableCallable():
    env = actions.Environment()
    env.tables["MyTable"] = actions.LookupFilter(name="T", error=None)
    env.tables["MyTable"].add(re.compile('abc'), 'xyz')
    assert 'xyz' == actions.UseTableCallable('abc', option="MyTable", env=env)