Mercurial > pydertron
comparison test_pydertron.py @ 35:6ddc83bb61f8 default tip
added another gc test
| author | Atul Varma <avarma@mozilla.com> |
|---|---|
| date | Mon, 10 May 2010 21:01:58 -0700 |
| parents | 739c87de4667 |
| children |
comparison
equal
deleted
inserted
replaced
| 34:739c87de4667 | 35:6ddc83bb61f8 |
|---|---|
| 2 import weakref | 2 import weakref |
| 3 import gc | 3 import gc |
| 4 from StringIO import StringIO | 4 from StringIO import StringIO |
| 5 | 5 |
| 6 import pydertron | 6 import pydertron |
| 7 from pydertron import jsexposed | |
| 7 | 8 |
| 8 class PydertronTests(unittest.TestCase): | 9 class PydertronTests(unittest.TestCase): |
| 9 def testNullFilesystem(self): | 10 def testNullFilesystem(self): |
| 10 stderr = StringIO() | 11 stderr = StringIO() |
| 11 sandbox = pydertron.JsSandbox(pydertron.NullFileSystem()) | 12 sandbox = pydertron.JsSandbox(pydertron.NullFileSystem()) |
| 32 sandbox.finish() | 33 sandbox.finish() |
| 33 del sandbox | 34 del sandbox |
| 34 gc.collect() | 35 gc.collect() |
| 35 self.assertEqual(wrt(), None) | 36 self.assertEqual(wrt(), None) |
| 36 | 37 |
| 38 def testGC3(self): | |
| 39 sandbox = pydertron.JsSandbox(pydertron.NullFileSystem()) | |
| 40 | |
| 41 stuff = [] | |
| 42 | |
| 43 @jsexposed | |
| 44 def bleh(x): | |
| 45 stuff.append(x) | |
| 46 | |
| 47 sandbox.set_globals(bleh=bleh) | |
| 48 sandbox.run_script("bleh({});") | |
| 49 wrt = weakref.ref(sandbox.rt) | |
| 50 sandbox.finish() | |
| 51 stuff.pop() | |
| 52 del sandbox | |
| 53 gc.collect() | |
| 54 self.assertEqual(wrt(), None) | |
| 55 | |
| 37 if __name__ == '__main__': | 56 if __name__ == '__main__': |
| 38 unittest.main() | 57 unittest.main() |
