From 41ac85cd6b68a0e6b1a53e79ae497e315008f12a Mon Sep 17 00:00:00 2001 From: vrde Date: Wed, 18 Apr 2018 14:48:23 +0200 Subject: Option --skip-bad-files now skips all kind of bad files --- pycco/main.py | 4 ++-- tests/test_pycco.py | 13 +++++++++++++ 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] -- cgit v1.2.1 From f5ee7d01be768b0138fbb28034d5690061aa1695 Mon Sep 17 00:00:00 2001 From: vrde Date: Fri, 27 Apr 2018 00:09:28 +0200 Subject: Add compatibility for Python 2.7 --- requirements.test.txt | 3 ++- tests/test_pycco.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/requirements.test.txt b/requirements.test.txt index 5db5948..6c8b8e3 100644 --- a/requirements.test.txt +++ b/requirements.test.txt @@ -1,3 +1,4 @@ hypothesis==1.18.1 -pytest-cov==2.2.0 +pytest-cov~=2.0 coveralls==1.1 +mock~=2.0 diff --git a/tests/test_pycco.py b/tests/test_pycco.py index 1be2683..cae1888 100644 --- a/tests/test_pycco.py +++ b/tests/test_pycco.py @@ -4,7 +4,10 @@ import tempfile import time import os.path import pytest -from unittest.mock import patch +try: + from unittest.mock import patch +except ImportError: + from mock import patch from hypothesis import given, example, assume from hypothesis.strategies import lists, text, booleans, choices, none -- cgit v1.2.1 From c7b01d3aeef3dd0786190d4c5330fcd800b7066e Mon Sep 17 00:00:00 2001 From: vrde Date: Sun, 29 Apr 2018 22:45:57 +0200 Subject: Alias --skip-bad-files to --ignore-errors --- pycco/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pycco/main.py b/pycco/main.py index 492058b..6db3a91 100644 --- a/pycco/main.py +++ b/pycco/main.py @@ -605,7 +605,9 @@ def main(): parser.add_option('-i', '--generate_index', action='store_true', help='Generate an index.html document with sitemap content') - parser.add_option('-s', '--skip-bad-files', action='store_true', + parser.add_option('-s', '--skip-bad-files', + '-e', '--ignore-errors', + action='store_true', dest='skip_bad_files', help='Continue processing after hitting a bad file') -- cgit v1.2.1