From: Ralph Giles Date: Thu, 4 Jul 2019 20:24:51 +0000 (-0700) Subject: Register custom test category markers. X-Git-Tag: 2.10.2~7^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c61b366c02de34da90695ff57592d3fda90ac207;p=thirdparty%2Fjinja.git Register custom test category markers. Since around pytest 3.6 it's been possible to register custom markers, and since version 4.5.0 pytest warns about any which are not registered. Register a list of such markers, extracted from those warnings, so they don't clutter the test output. --- diff --git a/tests/conftest.py b/tests/conftest.py index 04ac7844..107659b9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,12 +16,54 @@ from jinja2.utils import have_async_gen from jinja2 import Environment -def pytest_ignore_collect(path, config): +def pytest_ignore_collect(path): if 'async' in path.basename and not have_async_gen: return True return False +def pytest_configure(config): + '''Register custom marks for test categories.''' + custom_markers = [ + 'api', + 'byte_code_cache', + 'core_tags', + 'debug', + 'escapeUrlizeTarget', + 'ext', + 'extended', + 'filter', + 'for_loop', + 'helpers', + 'if_condition', + 'imports', + 'includes', + 'inheritance', + 'lexer', + 'lexnparse', + 'loaders', + 'lowlevel', + 'lrucache', + 'lstripblocks', + 'macros', + 'meta', + 'moduleloader', + 'parser', + 'regression', + 'sandbox', + 'set', + 'streaming', + 'syntax', + 'test_tests', + 'tokenstream', + 'undefined', + 'utils', + 'with_', + ] + for mark in custom_markers: + config.addinivalue_line('markers', mark + ': test category') + + @pytest.fixture def env(): '''returns a new environment.