From 7448bae42b58859d138593cbc9f662740d8b8037 Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Sun, 18 Mar 2012 23:36:57 -0400 Subject: [PATCH] Test that precompiler classes are used --- compressor/tests/test_base.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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):