The main purpose of distributing py.test is to speedup tests of actual applications (running all pypy tests already takes ages).
On the beggining of communication, master server sends to client import hook code, which then can import all needed libraries.
Libraries are uploaded server -> client if they're needed (when __import__ is called). Possible extension is to add some kind of checksum (md5?) and store files in some directory.
Previous experiments tried to run on the lowest level - when function/ method is called. This is pretty clear (you run as few code on client side as possible), but has got some drawbacks:
On client side (side really running tests) run some kind of cut-down session, which is imported by remote import at the very beginning and after that, we run desired tests (probably by importing whole test file which allows us to have top-level imports).
Then we transfer output data to server as string, possibly tweaking file names (which is quite easy).