From: <pj...@us...> - 2008-12-29 22:39:05
|
Revision: 5810 http://jython.svn.sourceforge.net/jython/?rev=5810&view=rev Author: pjenvey Date: 2008-12-29 22:38:59 +0000 (Mon, 29 Dec 2008) Log Message: ----------- move test389 to test_traceback_jy, add a new currently failing traceback test Added Paths: ----------- trunk/jython/Lib/test/test_traceback_jy.py Removed Paths: ------------- trunk/jython/bugtests/test389.py Added: trunk/jython/Lib/test/test_traceback_jy.py =================================================================== --- trunk/jython/Lib/test/test_traceback_jy.py (rev 0) +++ trunk/jython/Lib/test/test_traceback_jy.py 2008-12-29 22:38:59 UTC (rev 5810) @@ -0,0 +1,69 @@ +"""Misc traceback tests + +Made for Jython. +""" +import sys +import traceback +import unittest +from test import test_support + +if test_support.is_jython: + from java.awt import EventQueue + from java.lang import Runnable + +class TracebackTestCase(unittest.TestCase): + + def test_tb_across_threads(self): + if not test_support.is_jython: + return + + # http://bugs.jython.org/issue1533624 + class PyRunnable(Runnable): + def run(self): + raise TypeError('this is only a test') + try: + EventQueue.invokeAndWait(PyRunnable()) + except TypeError: + # XXX: + """ + self.assertEqual(tb_info(), + [('test_tb_across_threads', + 'EventQueue.invokeAndWait(PyRunnable())'), + ('run', + "raise TypeError('this is only a test')")]) + """ + else: + self.fail('Expected TypeError') + + def _test_reraise(self): + def raiser(): + raise Exception(), None, tb + try: + # Jython previously added raiser's frame to the traceback + raiser() + except Exception: + self.assertEqual(tb_info(), + [('test_reraise', 'raiser()'), + ('<module>', "raise Exception('foo')")]) + + else: + self.fail('Expected Exception') + + +try: + raise Exception('foo') +except Exception: + tb = sys.exc_info()[2] + + +def tb_info(): + # [2:] ignores filename/lineno + return [info[2:] for info in traceback.extract_tb(sys.exc_info()[2])] + + +def test_main(): + test_support.run_unittest(TracebackTestCase) + + +if __name__ == '__main__': + test_main() Deleted: trunk/jython/bugtests/test389.py =================================================================== --- trunk/jython/bugtests/test389.py 2008-12-29 17:26:45 UTC (rev 5809) +++ trunk/jython/bugtests/test389.py 2008-12-29 22:38:59 UTC (rev 5810) @@ -1,20 +0,0 @@ -''' -Test for Bug #1533624. A call that crosses threads causes a null pointer -exception when building a traceback. If it reappears instead of the -TypeError showing up a null pointer exception will be thrown. -''' - -from java.awt import EventQueue -from java.lang import Runnable - -class PyRunnable(Runnable): - def run(self): - raise TypeError, 'this is only a test' - -def g(): - EventQueue.invokeAndWait(PyRunnable()) - -try: - g() -except TypeError: - pass This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |