summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2017-10-09 09:23:08 -0700
committerAnthony Sottile <asottile@umich.edu>2017-10-09 09:52:37 -0700
commitbbe8d6d6c6bb91363f2947f5c05edecb141074dc (patch)
tree623388bf5fe5b7a7658e7738b3170ecb2d11f574 /tests
parent2e12a2024b525e94ff9f864e101160bf226d048b (diff)
downloadflake8-bbe8d6d6c6bb91363f2947f5c05edecb141074dc.tar.gz
Catch UnicodeDecodeError while parsing config files
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_config_file_finder.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/unit/test_config_file_finder.py b/tests/unit/test_config_file_finder.py
index 2a9f903..d8502e7 100644
--- a/tests/unit/test_config_file_finder.py
+++ b/tests/unit/test_config_file_finder.py
@@ -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 == []