diff options
| author | Anthony Sottile <asottile@umich.edu> | 2020-05-07 11:13:23 -0700 |
|---|---|---|
| committer | Anthony Sottile <asottile@umich.edu> | 2020-05-07 11:16:00 -0700 |
| commit | 609010ce7aeecc22a3c104e5c0eb39b3746ace7a (patch) | |
| tree | eafb1fff770c50068685100974f4697dd0dc1fb6 /tests | |
| parent | 0c3b8045a7b51aec7abf19dea94d5292cebeeea0 (diff) | |
| download | flake8-609010ce7aeecc22a3c104e5c0eb39b3746ace7a.tar.gz | |
Fix logical checks which report position out of bounds
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/integration/test_checker.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/integration/test_checker.py b/tests/integration/test_checker.py index 096b350..eaab5c3 100644 --- a/tests/integration/test_checker.py +++ b/tests/integration/test_checker.py @@ -5,6 +5,7 @@ import pytest from flake8 import checker from flake8._compat import importlib_metadata from flake8.plugins import manager +from flake8.processor import FileProcessor PHYSICAL_LINE = "# Physical line content" @@ -159,6 +160,27 @@ def test_line_check_results(plugin_target, len_results): assert file_checker.results == expected +def test_logical_line_offset_out_of_bounds(): + """Ensure that logical line offsets that are out of bounds do not crash.""" + + @plugin_func + def _logical_line_out_of_bounds(logical_line): + yield 10000, 'L100 test' + + file_checker = mock_file_checker_with_plugin(_logical_line_out_of_bounds) + + logical_ret = ( + '', + 'print("xxxxxxxxxxx")', + [(0, (1, 0)), (5, (1, 5)), (6, (1, 6)), (19, (1, 19)), (20, (1, 20))], + ) + with mock.patch.object( + FileProcessor, 'build_logical_line', return_value=logical_ret, + ): + file_checker.run_logical_checks() + assert file_checker.results == [('L100', 0, 0, 'test', None)] + + PLACEHOLDER_CODE = 'some_line = "of" * code' |
