From: <fwi...@us...> - 2008-10-16 12:15:33
|
Revision: 5422 http://jython.svn.sourceforge.net/jython/?rev=5422&view=rev Author: fwierzbicki Date: 2008-10-16 12:15:26 +0000 (Thu, 16 Oct 2008) Log Message: ----------- First make test107 pass in both python and jython Modified Paths: -------------- trunk/jython/bugtests/test107.py Modified: trunk/jython/bugtests/test107.py =================================================================== --- trunk/jython/bugtests/test107.py 2008-10-16 12:07:24 UTC (rev 5421) +++ trunk/jython/bugtests/test107.py 2008-10-16 12:15:26 UTC (rev 5422) @@ -1,59 +1,55 @@ """ Check some internal frame info """ - -import support - - import sys from types import ClassType def getinfo(): - """ Returns a tuple consisting of: - the name of the current module - the name of the current class or None - the name of the current function - the current line number - """ - try: - 1/0 - except: - tb = sys.exc_info()[-1] - frame = tb.tb_frame.f_back - modulename = frame.f_globals['__name__'] - funcname = frame.f_code.co_name - lineno = frame.f_lineno + """ Returns a tuple consisting of: + the name of the current module + the name of the current class or None + the name of the current function + the current line number + """ + try: + 1/0 + except: + tb = sys.exc_info()[-1] + frame = tb.tb_frame.f_back + modulename = frame.f_globals['__name__'] + funcname = frame.f_code.co_name + lineno = frame.f_lineno - if len(frame.f_code.co_varnames) == 0: - classname = None - else: - self = frame.f_locals[frame.f_code.co_varnames[0]] - myclass = self.__class__ - if type(myclass) == ClassType: - classname = myclass.__name__ - else: - classname = None + if len(frame.f_code.co_varnames) == 0: + classname = None + else: + self = frame.f_locals[frame.f_code.co_varnames[0]] + myclass = self.__class__ + if type(myclass) == ClassType: + classname = myclass.__name__ + else: + classname = None - return modulename, classname, funcname, lineno + return modulename, classname, funcname, lineno def foo(): - x = 99 - g = getinfo() - support.compare(g[0], "(__main__|test107)") - support.compare(g[1], "None") - support.compare(g[2], "foo") + x = 99 + g = getinfo() + assert (g[0] == "__main__" or g[0] == "test107") + assert (g[1] == None) + assert (g[2] == "foo") class Bar: - def baz(self): - g = getinfo() - support.compare(g[0], "(__main__|test107)") - support.compare(g[1], "Bar") - support.compare(g[2], "baz") + def baz(self): + g = getinfo() + assert (g[0] == "__main__" or g[0] == "test107") + assert (g[1] == "Bar") + assert (g[2] == "baz") g = getinfo() -support.compare(g[0], "(__main__|test107)") -support.compare(g[1], "None") -support.compare(g[2], "<module>") +assert (g[0] == "__main__" or g[0] == "test107") +assert (g[1] == None) +assert (g[2] == "<module>") foo() Bar().baz() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |