[svn r64007] port 64001-64004 to trunk
--HG-- branch : trunk
This commit is contained in:
		
							parent
							
								
									9c6e5aa7eb
								
							
						
					
					
						commit
						ef63510f42
					
				|  | @ -13,6 +13,8 @@ class Frame(object): | |||
|         self.raw = frame | ||||
| 
 | ||||
|     def statement(self): | ||||
|         if self.code.fullsource is None: | ||||
|             return py.code.Source("") | ||||
|         return self.code.fullsource.getstatement(self.lineno) | ||||
|     statement = property(statement, None, None, | ||||
|                          "statement this frame is at") | ||||
|  |  | |||
|  | @ -9,6 +9,18 @@ def test_frame_getsourcelineno_myself(): | |||
|     source, lineno = f.code.fullsource, f.lineno | ||||
|     assert source[lineno].startswith("        return sys._getframe(0)") | ||||
| 
 | ||||
| def test_getstatement_empty_fullsource(): | ||||
|     def func(): | ||||
|         return sys._getframe(0) | ||||
|     f = func() | ||||
|     f = py.code.Frame(f) | ||||
|     prop = f.code.__class__.fullsource | ||||
|     try: | ||||
|         f.code.__class__.fullsource = None | ||||
|         assert f.statement == py.code.Source("") | ||||
|     finally: | ||||
|         f.code.__class__.fullsource = prop | ||||
| 
 | ||||
| def test_code_from_func():  | ||||
|     co = py.code.Code(test_frame_getsourcelineno_myself)  | ||||
|     assert co.firstlineno | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue