Вопрос

When you are running tests in nose, I would like to display the filename and line number of the test itself, especially when it fails, on the command line so I can jump to the line in emacs. I have inserted some code into case.py to print out the name, I see that I could make a plugin that handles the prepareTestCase, but my question is is there a plugin that would do that?

here is my code : nose/case.py:

import inspect

...

def runTest(self, result):

 ...

 if not isinstance(test,Failure):
    print("  File \"%s\", line %s\n" % (
        inspect.getsourcefile(test.test),
        inspect.getsourcelines(test.test)[1]))
Это было полезно?

Решение

You can get the filename of the test and test name just by running nosetest with -v option. In addition, tests that fail will dump a full stack trace on error (which has line numbers). You can also use --pdb and --pdb-failure options to get into pdb debugger immediately after error or test failure.

Nose-progressive plugin has many bells and whistles in terms of formatting the output of the tests, including changing the template to satisfy any editor. Also, check out this nosemacs - emacs extension to provide easy nosetest integration. And if you just want line numbers, nose-machineout is your friend.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top