diff --git a/compressor/tests/test_base.py b/compressor/tests/test_base.py index 7a76f58..b276d79 100644 --- a/compressor/tests/test_base.py +++ b/compressor/tests/test_base.py @@ -19,6 +19,15 @@ def css_tag(href, **kwargs): return template % (href, rendered_attrs) +class TestPrecompiler(object): + """A filter whose output is always the string 'OUTPUT' """ + def __init__(self, content, filter_type=None, filename=None): + pass + + def input(self, **kwargs): + return 'OUTPUT' + + test_dir = os.path.abspath(os.path.join(os.path.dirname(__file__))) @@ -134,6 +143,18 @@ class CompressorTestCase(TestCase): finally: settings.COMPRESS_OUTPUT_DIR = old_output_dir + def test_precompiler_class_used(self): + original_precompilers = settings.COMPRESS_PRECOMPILERS + settings.COMPRESS_ENABLED = True + settings.COMPRESS_PRECOMPILERS = ( + ('text/foobar', 'compressor.tests.base.TestPrecompiler'), + ) + css = '' + css_node = CssCompressor(css) + output = BeautifulSoup(css_node.output('inline')) + self.assertEqual(output.text, 'OUTPUT') + settings.COMPRESS_PRECOMPILERS = original_precompilers + class CssMediaTestCase(TestCase): def setUp(self):