diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-08-27 19:44:24 -0500 |
|---|---|---|
| committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-08-27 19:44:24 -0500 |
| commit | 1631ab8ac719d1c2ab39df1bc8c41028683ef23e (patch) | |
| tree | 86be65dd40b1a0cc2f426af81152c03d57d59348 | |
| parent | e8cb26895eb9bb239f7f5fef2a3430876c05616b (diff) | |
| download | flake8-1631ab8ac719d1c2ab39df1bc8c41028683ef23e.tar.gz | |
Add failing test for NoneType in handle_error
There are rare cases when StyleGuide#handle_error might receive None
as the column_number. This adds the failing test to ensure we don't
regress the correct behaviour.
Related-to #214
| -rw-r--r-- | tests/unit/test_style_guide.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/unit/test_style_guide.py b/tests/unit/test_style_guide.py index 64a7fcd..8e714b7 100644 --- a/tests/unit/test_style_guide.py +++ b/tests/unit/test_style_guide.py @@ -185,6 +185,19 @@ def test_handle_error_notifies_listeners(select_list, ignore_list, error_code): formatter.handle.assert_called_once_with(error) +def test_handle_error_does_not_raise_type_errors(): + """Verify that we handle our inputs better.""" + listener_trie = mock.create_autospec(notifier.Notifier, instance=True) + formatter = mock.create_autospec(base.BaseFormatter, instance=True) + guide = style_guide.StyleGuide(create_options(select=['T111'], ignore=[]), + listener_trie=listener_trie, + formatter=formatter) + + assert 1 == guide.handle_error( + 'T111', 'file.py', 1, None, 'error found', 'a = 1' + ) + + @pytest.mark.parametrize('select_list,ignore_list,error_code', [ (['E111', 'E121'], [], 'E122'), (['E11', 'E12'], [], 'E132'), |
