From 19ccaaf90528435ea04fd028f6c06c71d2a4005b Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Mon, 19 Mar 2012 18:08:05 -0400 Subject: [PATCH] Test that exception is raised for nonexistent precompiler If the class provided to `COMPRESS_PRECOMPILERS` doesn't exist (but its module does), an exception should be raised. --- compressor/tests/test_base.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/compressor/tests/test_base.py b/compressor/tests/test_base.py index b276d79..535dd43 100644 --- a/compressor/tests/test_base.py +++ b/compressor/tests/test_base.py @@ -11,6 +11,7 @@ from compressor.base import SOURCE_HUNK, SOURCE_FILE from compressor.conf import settings from compressor.css import CssCompressor from compressor.js import JsCompressor +from compressor.exceptions import FilterDoesNotExist def css_tag(href, **kwargs): @@ -155,6 +156,17 @@ class CompressorTestCase(TestCase): self.assertEqual(output.text, 'OUTPUT') settings.COMPRESS_PRECOMPILERS = original_precompilers + def test_nonexistent_precompiler_error(self): + original_precompilers = settings.COMPRESS_PRECOMPILERS + settings.COMPRESS_ENABLED = True + settings.COMPRESS_PRECOMPILERS = ( + ('text/foobar', 'compressor.tests.base.NonexistentFilter'), + ) + css = '' + css_node = CssCompressor(css) + self.assertRaises(FilterDoesNotExist, css_node.output, 'inline') + settings.COMPRESS_PRECOMPILERS = original_precompilers + class CssMediaTestCase(TestCase): def setUp(self):