test_stack_saved.py 450 B

12345678910111213141516171819
  1. import greenlet
  2. import unittest
  3. class Test(unittest.TestCase):
  4. def test_stack_saved(self):
  5. main = greenlet.getcurrent()
  6. self.assertEqual(main._stack_saved, 0)
  7. def func():
  8. main.switch(main._stack_saved)
  9. g = greenlet.greenlet(func)
  10. x = g.switch()
  11. assert x > 0, x
  12. assert g._stack_saved > 0, g._stack_saved
  13. g.switch()
  14. assert g._stack_saved == 0, g._stack_saved