From 3ec0a76adb549c75e5700045fbf82423de126ece Mon Sep 17 00:00:00 2001 From: pedronis Date: Tue, 25 Nov 2008 18:28:40 +0100 Subject: [PATCH] [svn r60139] some minimal testing for Code.source/fullsource --HG-- branch : trunk --- py/code/testing/test_code.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/py/code/testing/test_code.py b/py/code/testing/test_code.py index e8cb9f8c5..cc99d67cc 100644 --- a/py/code/testing/test_code.py +++ b/py/code/testing/test_code.py @@ -83,3 +83,19 @@ def test_code_with_class(): class A: pass py.test.raises(TypeError, "py.code.Code(A)") + +if True: + def x(): + pass + +def test_code_fullsource(): + code = py.code.Code(x) + full = code.fullsource + assert 'test_code_fullsource()' in str(full) + +def test_code_source(): + code = py.code.Code(x) + src = code.source() + expected = """def x(): + pass""" + assert str(src) == expected