diff options
author | Eevee <eevee.git@veekun.com> | 2013-05-10 10:56:28 -0700 |
---|---|---|
committer | Eevee <eevee.git@veekun.com> | 2013-05-23 13:43:24 -0700 |
commit | 4b0a89c6ed7dcadb2ed34dd79e3a5ac3b12d9db3 (patch) | |
tree | 4a30624f4fadb4cea3a4a78cd77df9003ba2dc05 /scss/tests/conftest.py | |
parent | da4cc9125052473f6b149dc673bd212275509ec6 (diff) | |
download | pyscss-4b0a89c6ed7dcadb2ed34dd79e3a5ac3b12d9db3.tar.gz |
Add py.test wizardry for running a subset of file tests. Fixes #134.
Diffstat (limited to 'scss/tests/conftest.py')
-rw-r--r-- | scss/tests/conftest.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/scss/tests/conftest.py b/scss/tests/conftest.py new file mode 100644 index 0000000..9a3b73b --- /dev/null +++ b/scss/tests/conftest.py @@ -0,0 +1,36 @@ +"""py.test plugin configuration.""" + +import glob +import os.path +import re + +FILES_DIR = os.path.join(os.path.dirname(__file__), 'files') + +def pytest_generate_tests(metafunc): + """Inject the test files as parametrizations. + + Relies on the command-line option `--test-file-filter`, set by the root + conftest.py. + """ + + scss_files = glob.glob(os.path.join(FILES_DIR, '*/*.scss')) + test_file_filter = metafunc.config.getoption('test_file_filter') + if test_file_filter: + file_filters = [ + re.compile(filt) + for filt in test_file_filter.split(',') + ] + + filtered_scss_files = [] + for fn in scss_files: + relfn = os.path.relpath(fn, FILES_DIR) + for rx in file_filters: + if rx.search(relfn): + filtered_scss_files.append(fn) + break + + scss_files = filtered_scss_files + + metafunc.parametrize( + 'scss_file_pair', + [(fn, fn[:-5] + '.css') for fn in scss_files]) |