예제 #1
0
파일: test_fileIO.py 프로젝트: norro/ecto
def test_fileI(Scheduler, file_like_object, realfile=False):
    global cards
    plasm = ecto.Plasm()
    if not realfile:
        file_like_object.writelines(filetext)
        file_like_object.seek(0)
    reader = ecto_test.FileI(file=ecto.istream(file_like_object))
    printer = ecto_test.Printer()
    plasm.connect(reader[:] >> printer[:])
    sched = Scheduler(plasm)
    sched.execute()
    assert reader.outputs.output == cards[-1]
예제 #2
0
def test_fileI(Scheduler, file_like_object, realfile=False):
    global cards
    plasm = ecto.Plasm()
    if not realfile:
        file_like_object.writelines(filetext)
        file_like_object.seek(0)
    reader = ecto_test.FileI(file=ecto.istream(file_like_object))
    printer = ecto_test.Printer()
    plasm.connect(reader[:] >> printer[:])
    sched = Scheduler(plasm)
    sched.execute()
    assert reader.outputs.output == cards[-1]
예제 #3
0
def test_tendrils_serialization():
    t = ecto.Tendrils()
    t.declare("Hello",ecto.Tendril.createT('std::string'))

    t.declare("Woot",ecto.Tendril.createT('double'))
    t.Hello = 'World'
    t.Woot = math.pi
    ofs = StringIO()
    t.save(ecto.ostream(ofs))

    #grab the string
    ifs = StringIO(ofs.getvalue())

    t_ds = ecto.Tendrils()
    t_ds.load(ecto.istream(ifs))
    print 'loaded:'
    for key, val in t_ds.iteritems():
        print key, val.val
    assert t_ds.Woot == math.pi
    assert t_ds.Hello == 'World'
예제 #4
0
def test_tendrils_serialization():
    t = ecto.Tendrils()
    t.declare("Hello", ecto.Tendril.createT('std::string'))

    t.declare("Woot", ecto.Tendril.createT('double'))
    t.Hello = 'World'
    t.Woot = math.pi
    ofs = StringIO()
    t.save(ecto.ostream(ofs))

    #grab the string
    ifs = StringIO(ofs.getvalue())

    t_ds = ecto.Tendrils()
    t_ds.load(ecto.istream(ifs))
    print 'loaded:'
    for key, val in t_ds.iteritems():
        print key, val.val
    assert t_ds.Woot == math.pi
    assert t_ds.Hello == 'World'