1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
"""Evaluates all the tests that live in `scss/tests/files`.
A test is any file with a `.scss` extension. It'll be compiled, and the output
will be compared to the contents of a file named `foo.css`.
Currently, test files must be nested exactly one directory below `files/`.
This limitation is completely arbitrary.
"""
from __future__ import absolute_import
import os.path
import logging
import scss
console = logging.StreamHandler()
logger = logging.getLogger('scss')
logger.setLevel(logging.ERROR)
logger.addHandler(console)
def test_pair_programmatic(scss_file_pair):
scss_fn, css_fn, pytest_trigger = scss_file_pair
if pytest_trigger:
pytest_trigger()
with open(scss_fn) as fh:
source = fh.read()
try:
with open(css_fn) as fh:
expected = fh.read()
except IOError:
expected = ''
directory, _ = os.path.split(scss_fn)
include_dir = os.path.join(directory, 'include')
scss.config.STATIC_ROOT = os.path.join(directory, 'static')
compiler = scss.Scss(scss_opts=dict(style='expanded'), search_paths=[include_dir])
actual = compiler.compile(source)
# Normalize leading and trailing newlines
actual = actual.strip('\n')
expected = expected.strip('\n')
assert expected == actual
|