diff options
| author | Eric N. Vander Weele <ericvw@gmail.com> | 2020-06-02 09:40:12 -0400 |
|---|---|---|
| committer | Anthony Sottile <asottile@umich.edu> | 2020-06-02 11:38:44 -0700 |
| commit | a68d4d01722bfbf0ec2179383acc13a7d87eb499 (patch) | |
| tree | d10609cc0db0b3bbca7ba1ca4af3c3dc47df25eb /tests | |
| parent | 40716454a285b7a3f63c398f78106fafd5c668e7 (diff) | |
| download | flake8-a68d4d01722bfbf0ec2179383acc13a7d87eb499.tar.gz | |
processor: Catch SyntaxError also when generating tokens for a file
`tokenize.generate_tokens()` can also raise `SyntaxError` in addition to
`tokenize.TokenError`.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/integration/test_main.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/integration/test_main.py b/tests/integration/test_main.py index ab10bf9..ce8ad13 100644 --- a/tests/integration/test_main.py +++ b/tests/integration/test_main.py @@ -162,6 +162,17 @@ def test_tokenization_error_but_not_syntax_error(tmpdir, capsys): assert err == '' +def test_tokenization_error_is_a_syntax_error(tmpdir, capsys): + """Test when tokenize raises a SyntaxError.""" + with tmpdir.as_cwd(): + tmpdir.join('t.py').write('if True:\n pass\n pass\n') + _call_main(['t.py'], retv=1) + + out, err = capsys.readouterr() + assert out == 't.py:1:1: E902 IndentationError: unindent does not match any outer indentation level\n' # noqa: E501 + assert err == '' + + def test_bug_report_successful(capsys): """Test that --bug-report does not crash.""" _call_main(['--bug-report']) |
