0

I have inherited a large number of python scripts that don't come with unit tests (good times). Eventually I will have unit tests for most of these scripts. Until then I would like to force python to evaluate every potential code path because I'm finding lovely things like name errors in function calls.

Is there a way to force python to evaluate every line of code (including lines in uncalled functions or exception handlers) other than unit tests?

AlexLordThorsen
  • 8,057
  • 5
  • 48
  • 103
  • Related: http://stackoverflow.com/questions/6025714/tools-for-static-type-checking-in-python – Gerrat Jan 14 '15 at 20:14
  • Not *exactly* what you're looking for, but would probably be useful: http://www.pylint.org/ – NPE Jan 14 '15 at 20:14
  • I am new to Python, but have been mostly impressed with the static checking that is done by PyCharm IDE. The column containing scroll bar for the code editing window shows the position of all the warnings. I suspect under the hood it's running a well known static code checking tool that one of the other commenters have suggested. In any case, I try to annotate as many variables and parameters as I can, resolve all the major warnings, and make that little box at the top of the scroll bar turn green. – selbie Jan 14 '15 at 20:21

2 Answers2

0

No, there is no such facility, although you may find a tool like pylint useful.

kindall
  • 178,883
  • 35
  • 278
  • 309
0

If, by evaluate, you mean "run every line of code," you'd do this:

  1. Press the ESC key
  2. Hold CNTRL + A on a PC, but CMD + A on a Mac
  3. Hit SHIFT + RETURN on a Mac (I think that would be CNTRL + RETURN on a PC)
jps
  • 13
  • 4