summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvrde <agranzot@gmail.com>2018-04-18 14:48:23 +0200
committervrde <agranzot@gmail.com>2018-04-19 11:44:25 +0200
commit41ac85cd6b68a0e6b1a53e79ae497e315008f12a (patch)
tree01225c2bd561fa788feef685432998ac340b33c7
parentfce7f146a3c70e637af86e9fa9856515d3165b8f (diff)
downloadpycco-41ac85cd6b68a0e6b1a53e79ae497e315008f12a.tar.gz
Option --skip-bad-files now skips all kind of bad files
-rw-r--r--pycco/main.py4
-rw-r--r--tests/test_pycco.py13
2 files changed, 15 insertions, 2 deletions
diff --git a/pycco/main.py b/pycco/main.py
index f0d4fcf..492058b 100644
--- a/pycco/main.py
+++ b/pycco/main.py
@@ -521,9 +521,9 @@ def process(sources, preserve_paths=True, outdir=None, language=None,
print("pycco: {} -> {}".format(s, dest))
generated_files.append(dest)
- except UnicodeDecodeError:
+ except (ValueError, UnicodeDecodeError) as e:
if skip:
- print("pycco [FAILURE]: {}".format(s))
+ print("pycco [FAILURE]: {}, {}".format(s, e))
else:
raise
diff --git a/tests/test_pycco.py b/tests/test_pycco.py
index 6db8265..1be2683 100644
--- a/tests/test_pycco.py
+++ b/tests/test_pycco.py
@@ -4,6 +4,7 @@ import tempfile
import time
import os.path
import pytest
+from unittest.mock import patch
from hypothesis import given, example, assume
from hypothesis.strategies import lists, text, booleans, choices, none
@@ -160,6 +161,18 @@ def test_process(preserve_paths, index, choice):
language=lang_name)
+@patch('pygments.lexers.guess_lexer')
+def test_process_skips_unknown_languages(mock_guess_lexer):
+ class Name:
+ name = 'this language does not exist'
+ mock_guess_lexer.return_value = Name()
+
+ with pytest.raises(ValueError):
+ p.process(['LICENSE'], outdir=tempfile.gettempdir(), skip=False)
+
+ p.process(['LICENSE'], outdir=tempfile.gettempdir(), skip=True)
+
+
@given(lists(lists(text(min_size=1), min_size=1, max_size=30), min_size=1), lists(text(min_size=1), min_size=1))
def test_generate_index(path_lists, outdir_list):
file_paths = [os.path.join(*path_list) for path_list in path_lists]