mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 21:16:54 +00:00
Catch UnicodeDecodeError while parsing config files
This commit is contained in:
parent
2e12a2024b
commit
bbe8d6d6c6
2 changed files with 27 additions and 8 deletions
|
|
@ -1,3 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Tests for the ConfigFileFinder."""
|
||||
import configparser
|
||||
import os
|
||||
|
|
@ -135,4 +136,14 @@ def test_local_configs_double_read():
|
|||
])
|
||||
def test_read_config_catches_broken_config_files(files):
|
||||
"""Verify that we do not allow the exception to bubble up."""
|
||||
assert config.ConfigFileFinder._read_config(files)[1] == []
|
||||
_, parsed = config.ConfigFileFinder._read_config(files)
|
||||
assert BROKEN_CONFIG_PATH not in parsed
|
||||
|
||||
|
||||
def test_read_config_catches_decoding_errors(tmpdir):
|
||||
"""Verify that we do not allow the exception to bubble up."""
|
||||
setup_cfg = tmpdir.join('setup.cfg')
|
||||
# pick an encoding that's unlikely to be a default
|
||||
setup_cfg.write_binary(u'[x]\ny = €'.encode('cp1252'))
|
||||
_, parsed = config.ConfigFileFinder._read_config(setup_cfg.strpath)
|
||||
assert parsed == []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue