add a helper to get a function's code

--HG--
branch : trunk
This commit is contained in:
Benjamin Peterson
2010-04-23 20:39:40 -05:00
parent f16d54f9a8
commit d1b45ef3d4
3 changed files with 13 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
import sys
import types
import py
from py.builtin import set, frozenset, reversed, sorted
@@ -146,3 +147,8 @@ def test_tryimport():
assert x == py
x = py.builtin._tryimport('asldkajsdl', 'py.path')
assert x == py.path
def test_getcode():
code = py.builtin._getcode(test_getcode)
assert isinstance(code, types.CodeType)
assert py.builtin._getcode(4) is None