summaryrefslogtreecommitdiff
path: root/tests/test_pycco.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_pycco.py')
-rw-r--r--tests/test_pycco.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_pycco.py b/tests/test_pycco.py
index 6db8265..cae1888 100644
--- a/tests/test_pycco.py
+++ b/tests/test_pycco.py
@@ -4,6 +4,10 @@ import tempfile
import time
import os.path
import pytest
+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
@@ -160,6 +164,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]