Files
sousa-gecko/tools/tryselect/test/conftest.py
T
Andrew Halberstadt d8013f62f2 Bug 1413928 - [tryselect] Add python unittest for templates r=davehunt
This makes use of pytest's generation feature. To add a new
template test, just add a new entry containing the input and
expected output to the dict in test_templates.py

MozReview-Commit-ID: 4qMefYHMjAp
2017-11-21 10:11:00 -05:00

18 lines
788 B
Python

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import absolute_import, print_function, unicode_literals
def pytest_generate_tests(metafunc):
if all(fixture in metafunc.fixturenames for fixture in ('template', 'args', 'expected')):
def load_tests():
for template, tests in metafunc.module.TEMPLATE_TESTS.items():
for args, expected in tests:
yield (template, args, expected)
tests = list(load_tests())
ids = ['{} {}'.format(t[0], ' '.join(t[1])).strip() for t in tests]
metafunc.parametrize('template,args,expected', tests, ids=ids)