diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-02-23 11:17:11 -0600 |
|---|---|---|
| committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-02-23 11:17:11 -0600 |
| commit | 5ee061b810caf03025927f2e8fc7fb15fdcabd58 (patch) | |
| tree | 139d729aa1df0b8cec48042754a50f30c67708cc /tests | |
| parent | 28f4811cb99418c43dd90a9dc31d0ec1ba06c8b7 (diff) | |
| download | flake8-5ee061b810caf03025927f2e8fc7fb15fdcabd58.tar.gz | |
Add line splitting and file reading
Add some tests around reading lines and striping UTF BOMs
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit/test_file_checker.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unit/test_file_checker.py b/tests/unit/test_file_checker.py new file mode 100644 index 0000000..e26bc83 --- /dev/null +++ b/tests/unit/test_file_checker.py @@ -0,0 +1,26 @@ +"""Tests for the FileChecker class.""" +from flake8 import checker + +import pytest + + +def test_read_lines_splits_lines(): + """Verify that read_lines splits the lines of the file.""" + file_checker = checker.FileChecker(__file__, []) + lines = file_checker.read_lines() + assert len(lines) > 5 + assert '"""Tests for the FileChecker class."""\n' in lines + + +@pytest.mark.parametrize('first_line', [ + '\xEF\xBB\xBF"""Module docstring."""\n', + '\uFEFF"""Module docstring."""\n', +]) +def test_strip_utf_bom(first_line): + r"""Verify that we strip '\xEF\xBB\xBF' from the first line.""" + lines = [first_line] + file_checker = checker.FileChecker('stdin', []) + file_checker.lines = lines[:] + file_checker.strip_utf_bom() + assert file_checker.lines != lines + assert file_checker.lines[0] == '"""Module docstring."""\n' |
