weird.py 721 B

1234567891011121314151617181920212223
  1. from __future__ import division, absolute_import
  2. import unittest
  3. from twisted.internet import defer
  4. # Used in test_tests.UnhandledDeferredTests
  5. class TestBleeding(unittest.TestCase):
  6. """This test creates an unhandled Deferred and leaves it in a cycle.
  7. The Deferred is left in a cycle so that the garbage collector won't pick it
  8. up immediately. We were having some problems where unhandled Deferreds in
  9. one test were failing random other tests. (See #1507, #1213)
  10. """
  11. def test_unhandledDeferred(self):
  12. try:
  13. 1/0
  14. except ZeroDivisionError:
  15. f = defer.fail()
  16. # these two lines create the cycle. don't remove them
  17. l = [f]
  18. l.append(l)