Hi,
I found a simple way to gain control of the twisted
clock so that the time in the tests is not subject to the
horsepower of the machine. A few poker-network tests may
fail if run on a slow machine, which is extremely inconvenient.
The solution is in
twisted/test/test_internet.py
def testCallLaterOrder2(self):
# This time destroy the clock resolution so that it fails reliably
# even on systems that don't have a crappy clock resolution.
def seconds():
return int(time.time())
from twisted.internet import base
from twisted.python import runtime
base_original = base.seconds
runtime_original = runtime.seconds
base.seconds = seconds
runtime.seconds = seconds
def cleanup(x):
runtime.seconds = runtime_original
base.seconds = base_original
return x
return maybeDeferred(self.testCallLaterOrder).addBoth(cleanup)
Of course we don't want the seconds to return a coarser grain
time. Instead we want it to return a counter + 1. 10 seconds == 10 calls.
This conversion allows both control of the time and no delay.
Cheers,
--
+33 1 76 60 72 81 Loic Dachary mailto:[EMAIL PROTECTED]
http://dachary.org/loic/gpg.txt sip:[EMAIL PROTECTED]
_______________________________________________
Pokersource-users mailing list
[email protected]
https://mail.gna.org/listinfo/pokersource-users