Merge branch 'bug/157' into 'master'

Handle errors reported in empty files

*Description of changes*

Some plugins return errors in empty files which previously caused an IndexError.

*Related to:*  #157 

See merge request !71
This commit is contained in:
Ian Cordasco 2016-07-10 01:29:17 +00:00
commit edd84fba52
3 changed files with 19 additions and 4 deletions

View file

@ -51,7 +51,15 @@ def test_show_source_returns_nothing_when_not_showing_source():
formatter = base.BaseFormatter(options(show_source=False))
assert formatter.show_source(
style_guide.Error('A000', 'file.py', 1, 1, 'error text', 'line')
) is None
) is ''
def test_show_source_returns_nothing_when_there_is_source():
"""Ensure we return nothing when there is no line."""
formatter = base.BaseFormatter(options(show_source=True))
assert formatter.show_source(
style_guide.Error('A000', 'file.py', 1, 1, 'error text', None)
) is ''
@pytest.mark.parametrize('line, column', [