1

I have a python nose test function

def test_foo():
    a = 1
    b = 2

and I want to get the source code as string("\ta = 1\n\tb =2") in my customized plugin. I try

def startTest(self, test):
    print inspect.getsource(test)

Above code cannot work. How to make it work?

guile chao
  • 93
  • 1
  • 2
  • 5
  • Maybe you tested it in an interpreter. I know, it is a too late answer but maybe this link is useful for you: https://stackoverflow.com/questions/427453/how-can-i-get-the-source-code-of-a-python-function?rq=1 –  May 20 '18 at 11:59

0 Answers0