diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-07-10 01:29:17 +0000 |
|---|---|---|
| committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-07-10 01:29:17 +0000 |
| commit | edd84fba5298cedfb3c6f456a00107f1d3f642c2 (patch) | |
| tree | f383a70924372f6e8c3a691f455d469cb2f74d03 /tests | |
| parent | 7ea6da2d55b8c5120358ba8aec16bde8f798e371 (diff) | |
| parent | e977c6671a470d431ffe869069d95692e846d261 (diff) | |
| download | flake8-edd84fba5298cedfb3c6f456a00107f1d3f642c2.tar.gz | |
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
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit/test_base_formatter.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/unit/test_base_formatter.py b/tests/unit/test_base_formatter.py index dc4a95c..f148806 100644 --- a/tests/unit/test_base_formatter.py +++ b/tests/unit/test_base_formatter.py @@ -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', [ |
