mgedmin / coverage-highlight.vim

Vim plugin to highlight Python source code lines that lack test coverage
MIT License
56 stars 5 forks source link

Exception when coverage has branch info: ValueError: invalid literal for int() with base 10: 'exit' #9

Closed diefans closed 5 years ago

diefans commented 5 years ago
Traceback (most recent c
all last):
  File "/home/olli/.pyenv/versions/neovim3/lib/python3.7/site-packages/pynvim/plugin/script_host.py", line 93, in python_execute
    exec(script, self.module.__dict__)
  File "<string>", line 1, in <module>
  File "/home/olli/.local/share/nvim/plugged/coverage-highlight.vim/pythonx/coverage_highlight.py", line 338, in highlight
    parse_coverage_output(output, relfilename)
  File "/home/olli/.local/share/nvim/plugged/coverage-highlight.vim/pythonx/coverage_highlight.py", line 208, in parse_coverage_output
    parse_lines(missing, signs)
  File "/home/olli/.local/share/nvim/plugged/coverage-highlight.vim/pythonx/coverage_highlight.py", line 158, in wrapped
    return fn(*args, **kw)
  File "/home/olli/.local/share/nvim/plugged/coverage-highlight.vim/pythonx/coverage_highlight.py", line 257, in parse_lines
    src, dst = map(int, item.split('->'))
ValueError: invalid literal for int() with base 10: 'exit'

coverage report looks like this:

---------- coverage: platform linux2, python 2.7.15-final-0 ----------
Name                             Stmts   Miss Branch BrPart     Cover   Missing
-------------------------------------------------------------------------------
src/lambda_function.py              42      5      6      2    85.42%   29-30, 51-52, 85, 54->exit, 84->85

the code looks like this:

def foobar():
    try:
        foo = int(os.environ.get('FOO', 3))
    except ValueError:
        pass
    else:
        if foo:  # <--- this is the branch to exit
            # do something here
            pass 
mgedmin commented 5 years ago

Oooh, thank you for this well-written bug report!

mgedmin commented 5 years ago

Should be fixed now!

diefans commented 5 years ago

thanks man!