diff options
author | Georg Brandl <georg@python.org> | 2014-09-20 11:57:59 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-09-20 11:57:59 +0200 |
commit | f62d7598287b7f5026637811ed5913b51c649f3f (patch) | |
tree | 71b24c3730eefcc8a9574309b26955149687f839 | |
parent | b4e544bcfff8ad69d3aafb54b1060ebb53e71df6 (diff) | |
download | pygments-f62d7598287b7f5026637811ed5913b51c649f3f.tar.gz |
Don't test lexer classes from arbitrary plugins.
-rw-r--r-- | pygments/lexers/__init__.py | 7 | ||||
-rw-r--r-- | tests/test_basic_api.py | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/pygments/lexers/__init__.py b/pygments/lexers/__init__.py index 369b7cc4..80545b6c 100644 --- a/pygments/lexers/__init__.py +++ b/pygments/lexers/__init__.py @@ -166,15 +166,16 @@ def get_lexer_for_mimetype(_mime, **options): raise ClassNotFound('no lexer for mimetype %r found' % _mime) -def _iter_lexerclasses(): +def _iter_lexerclasses(plugins=True): """Return an iterator over all lexer classes.""" for key in sorted(LEXERS): module_name, name = LEXERS[key][:2] if name not in _lexer_cache: _load_lexers(module_name) yield _lexer_cache[name] - for lexer in find_plugin_lexers(): - yield lexer + if plugins: + for lexer in find_plugin_lexers(): + yield lexer def guess_lexer_for_filename(_fn, _text, **options): diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py index e6b9b325..6069f97c 100644 --- a/tests/test_basic_api.py +++ b/tests/test_basic_api.py @@ -80,7 +80,7 @@ def test_lexer_classes(): assert txt == test_content, "%s lexer roundtrip failed: %r != %r" % \ (cls.name, test_content, txt) - for lexer in lexers._iter_lexerclasses(): + for lexer in lexers._iter_lexerclasses(plugins=False): yield verify, lexer @@ -110,7 +110,7 @@ def test_lexer_options(): inst = cls(ensurenl=False, stripall=True) ensure(inst.get_tokens('a\nb\n\n'), 'a\nb') - for lexer in lexers._iter_lexerclasses(): + for lexer in lexers._iter_lexerclasses(plugins=False): if lexer.__name__ == 'RawTokenLexer': # this one is special continue |