[Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/unittests test_tasklet_become.py, NONE, 1.1

Stefan Drees sdrees at centera.de
Fri Apr 9 01:36:09 CEST 2004


Update of /home/cvs/slpdev/src/2.3/dev/Stackless/unittests
In directory centera.de:/tmp/cvs-serv12141

Added Files:
	test_tasklet_become.py 
Log Message:
First shot at a unit test for tasklet.become() (works with current stackless).


--- NEW FILE: test_tasklet_become.py ---
import unittest
"""Unsure, if an explicit tasklet.become(tasklet()) should be tested.  """

from sys import stdout
from stackless import *

class TestTaskletBecome(unittest.TestCase):
    def testSimpleTaskletBecome(self):
	def f(ch):
	    print "\tBecoming a tasklet inside f(ch)"
	    #become_tasklet()
    	    got = tasklet().capture(42)
     	    yum = repr(got)
    	    print "\tCaptured inside    f(ch):", yum
    	    print ch.receive()
	    print "\tFunction f(ch) finished"

    	ch = channel()
	print
    	print "First in main(TestTaskletBecome):",
    	foo =  getcurrent()
	print foo
    	print "Now calling a function f(ch)"
    	bar = f(ch)
	print "Back in  main(TestTaskletBecome):",bar
    	ch.send("Did it work out right?")
	self.assertEquals(foo,bar)


if __name__ == '__main__':
    import sys
    if not sys.argv[1:]:
        sys.argv.append('-v')
    unittest.main()




_______________________________________________
Stackless-checkins mailing list
Stackless-checkins at stackless.com
http://www.stackless.com/mailman/listinfo/stackless-checkins



More information about the Stackless-checkins mailing list