assertTrue(fooClass instanceof PyClass);
PyObject foo = fooClass.__call__();
PyObject fooVal = foo.__getattr__("val");
assertTrue(fooVal instanceof PyInteger);
PyInteger val = (PyInteger) fooVal;
assertEquals(17, val.getValue());
PyObject function = interpreter.get("outside_add_squared");
assertTrue("method class: " + function.getClass(), function instanceof PyFunction);
function.__call__(foo, new PyInteger(3));
fooVal = foo.__getattr__("val");
assertTrue(fooVal instanceof PyInteger);
val = (PyInteger) fooVal;
assertEquals(26, val.getValue());
JythonWritableWrapper wrappedFoo = new JythonWritableWrapper(foo);
PyObject newOtherMethod = wrappedFoo.__getattr__("new_other");
assertTrue(newOtherMethod instanceof PyMethod);
newOtherMethod.__call__();
function.__call__(wrappedFoo, new PyInteger(2));
fooVal = foo.__getattr__("val");
assertTrue(fooVal instanceof PyInteger);
val = (PyInteger) fooVal;
assertEquals(30, val.getValue());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
wrappedFoo.write(dos);
byte[] data = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(data);
DataInputStream dis = new DataInputStream(bais);
PyObject foo2 = fooClass.__call__();
PyObject foo2Val = foo2.__getattr__("val");
assertTrue(foo2Val instanceof PyInteger);
PyInteger val2 = (PyInteger) foo2Val;
assertEquals(17, val2.getValue());
JythonWritableWrapper wrappedFoo2 = new JythonWritableWrapper(foo2);
foo2Val = wrappedFoo2.getPyObject().__getattr__("val");
assertTrue(foo2Val instanceof PyInteger);
val2 = (PyInteger) foo2Val;
assertEquals(17, val2.getValue());
wrappedFoo2.readFields(dis);
foo2Val = wrappedFoo2.getPyObject().__getattr__("val");
assertTrue(foo2Val instanceof PyInteger);
val2 = (PyInteger) foo2Val;
assertEquals(30, val2.getValue());
}