[TIP] mock-ing java classes in Jython?

Fredrik Håård fredrik at haard.se
Sun Jul 31 03:23:31 PDT 2011


Hi all (and thanks for the pizza! =),

I'd like to set up a test suite for an embedded J2ME application. Most of
the code is cleanly separated from the platform since it runs on multiple
platforms, and I wanted to use Jython to replace the platform-specific parts
and run both unit and scenario testing on the common parts.

However, naive replacement of the class definitions does not seem to work,
and trying to use mock to patch a java class like this:

with mock.patch('my.device.DeviceHandler') as devicehandler:

i get:

AttributeError: 'javapackage' object has no attribute 'DeviceHandler'

Is it possible to get the behavior I want?

-- 
/f

I reject your reality and substitute my own.
http://courteous.ly/yp3Zgd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20110731/537a0482/attachment.html>


More information about the testing-in-python mailing list