diff options
author | Zach Smith <zd@zdsmith.com> | 2018-05-02 09:44:51 -0400 |
---|---|---|
committer | Zach Smith <zd@zdsmith.com> | 2018-05-02 09:44:51 -0400 |
commit | 8377314cd8024f2e0c1584eba79a57db1f488eb1 (patch) | |
tree | 60e87068c8bf24965459c89eadc73604a7ab558e /tests/test_pycco.py | |
parent | 57d0aaa4cff222ccd20b7d6f78f96ac6bb2225c0 (diff) | |
parent | 9404e8d7cd794e0c2d037a885e49a9c9f6544b37 (diff) | |
download | pycco-minor-fixes.tar.gz |
Merge branch 'master' into minor-fixesminor-fixes
Diffstat (limited to 'tests/test_pycco.py')
-rw-r--r-- | tests/test_pycco.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/tests/test_pycco.py b/tests/test_pycco.py index 53fa74f..845bfe8 100644 --- a/tests/test_pycco.py +++ b/tests/test_pycco.py @@ -1,16 +1,24 @@ from __future__ import absolute_import + import copy import os +import os.path import tempfile import time -import os.path + import pytest -from hypothesis import given, example -from hypothesis.strategies import lists, text, booleans, choices, none import pycco.generate_index as generate_index -from pycco.languages import supported_languages import pycco.main as p +from hypothesis import assume, example, given +from hypothesis.strategies import booleans, choices, lists, none, text +from pycco.languages import supported_languages + +try: + from unittest.mock import patch +except ImportError: + from mock import patch + PYTHON = supported_languages['.py'] @@ -164,6 +172,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) + + one_or_more_chars = text(min_size=1, max_size=255) paths = lists(one_or_more_chars, min_size=1, max_size=30) @given( |