def run(source_code): """Run the source code. :param source_code: code to run :type source_code: :class:`str` """ eval_(parse(lex(source_code)), Context(apply_stencil))
def test_calls_eval(self, context): # [...] * 10 would create a list of the same instance; that is not what # we want. # Just test a simple serial program without branches. Branches are # tested more in `test_bytecodes.py'. bytecodes = [ create_autospec(Bytecode, spec_set=True) for _ in xrange(10)] eval_(bytecodes, context) for bytecode in bytecodes: bytecode.eval.assert_called_once_with(context)
def test_sets_program_length(self, context): bytecodes = [MagicMock()] * 10 eval_(bytecodes, context) assert context.program_length == 10